
#include <iostream>
using namespace std;

const int MAX=100000;

struct sta
{
  int loc, gas;
};

sta station[MAX];
int s,c;
int Level[MAX];
bool C[MAX], CC[MAX];

//sorts station[]
void Sort(int n){
   sta temp;

   for(int j=1;j<n;j++){
    temp = station[j];
    int i=j-1;
    while(i>-1 && station[i].loc>temp.loc){
      station[i+1]=station[i];
      i--;
    } 
    station[i+1]=temp;
   }
   
}

int main(){
  int caseno=1;

  cin>>c>>s;
  while(c>0){
    for(int i=0;i<s;i++)
      cin>>station[i].loc>>station[i].gas;
    //sort station[][] on loc field
    Sort(s);

/*
//print station[]
  for(int i=0;i<s;i++) cout<<station[i].loc<<','<<station[i].gas<<" ";
  cout<<endl;
*/

    //proceed around in direction C
    for(int i=0;i<s;i++) C[i]=false; 
    Level[0]=0;
    for(int i=1;i<s;i++)
      Level[i]=Level[i-1]-(station[i].loc-station[i-1].loc)+station[i-1].gas;
    //find min
    int min=0;
    for(int i=1;i<s;i++)
      if(Level[i]<min) min=Level[i];
    //mark mins
    for(int i=0;i<s;i++)
      if(Level[i]==min) C[i]=true;

    //now proceed around in direction CC
    for(int i=s-1;i>-1;i--) CC[i]=false;
    Level[s-1]=0;
    for(int i=s-2;i>-1;i--)
      Level[i]=Level[i+1]-(station[i+1].loc-station[i].loc)+station[i+1].gas;
    //find min
    min=0;
    for(int i=1;i<s;i++)
      if(Level[i]<min) min=Level[i];
    //mark mins
    for(int i=0;i<s;i++)
      if(Level[i]==min) CC[i]=true;

   //print info
   cout << "Case " << caseno++ << ":";
   for(int i=0;i<s;i++){
     if(C[i] && CC[i]) cout<<' '<<station[i].loc<<" CCC";
     else if(C[i]) cout<<' '<<station[i].loc<<" C";
     else if (CC[i]) cout<<' '<<station[i].loc<<" CC";
   }
   cout<<endl; 

   cin>>c>>s;
  }

  return 0;
}
