#include <iostream>
using namespace std;

const int MAXSTATIONS = 100000;

void determineClockWise(int len, int n, int* locs, int* miles, bool* clock)
{
	int num[MAXSTATIONS], left[MAXSTATIONS];
	int next[MAXSTATIONS];

	for(int i=0; i<n-1; i++) {
		next[i] = locs[i+1]-locs[i];
		num[i] = left[i] = 0;
	}
	next[n-1] = len-locs[n-1]+locs[0];
	num[n-1] = left[n-1] = 0;

	for(int j=n-1; j>=0; j--) {
		int currleft = 0;
		int m = 0;
		int k = j;			// arrive at station k with currleft miles available
		while (m<n && currleft+miles[k] >= next[k]) {
			int k1 = (k+1)%n;
			m += num[k1]+1;
			currleft += miles[k]-next[k]+left[k1];
			k = (k+num[k1]+1)%n;
		}
		clock[j] = (m>=n);
		num[j] = m;
		left[j] = currleft;
	}
/*
	for(int i=0; i<n; i++)
		cout << num[i] << ' ';
	cout << endl;
	for(int i=0; i<n; i++)
		cout << left[i] << ' ';
	cout << endl;
/* */
}

void swap(int a[], int b[], int i, int j)
{
	int tmp = a[i];
	a[i] = a[j];
	a[j] = tmp;
	tmp = b[i];
	b[i] = b[j];
	b[j] = tmp;
}

int partition(int a[], int b[], int low, int high)
{
	int med = (low+high)/2;
	if (a[low] > a[med])
		swap(a, b, low, med);
	if (a[med] > a[high])
		swap(a, b, med, high);
	if (a[low] > a[med])
		swap(a, b, low, med);
	swap(a, b, low+1, med);
	int i=low+1;
	int j=high;
	while (i<j) {
		while (a[++i] < a[low+1])
			;
		while (a[--j] > a[low+1])
			;
		if (i<j)
			swap(a, b, i, j);
	}
	swap(a, b, low+1, j);
	return j;
}

void qsort(int a[], int b[], int low, int high)
{
	if (high-low > 20) {
		int index = partition(a, b, low, high);
		qsort(a, b, low, index-1);
		qsort(a, b, index+1, high);
	}
	else {
		int n=high-low+1;
		for(int i=0; i<n-1; i++) {
			for(int j=low; j<high; j++) {
				if (a[j] > a[j+1])
					swap(a, b, j, j+1);
			}
		}
	}
}

int main()
{
	int len, n;
	int locs[MAXSTATIONS], miles[MAXSTATIONS];
	bool clock[MAXSTATIONS], cclock[MAXSTATIONS];
	int icase=0;

	cin >> len >> n;
	while (len > 0) {
		icase++;
		for(int i=0; i<n; i++)
			cin >> locs[i] >> miles[i];
		qsort(locs, miles, 0, n-1);
/*
*/
/* 
		for(int i=0; i<n; i++)
			cout << locs[i] << ' ';
		cout << endl;
		for(int i=0; i<n; i++)
			cout << miles[i] << ' ';
		cout << endl;
/* */
		determineClockWise(len, n, locs, miles, clock);
		for(int i=0; i<n/2; i++) {
			int temp = miles[i];
			miles[i] = miles[n-1-i];
			miles[n-1-i] = temp;
			temp = len-1-locs[i];
			locs[i] = len-1-locs[n-1-i];
			locs[n-1-i] = temp;
		}
		if (n%2 == 1)
			locs[n/2] = len-1-locs[n/2];
		determineClockWise(len, n, locs, miles, cclock);
		cout << "Case " << icase << ":";
		for(int i=0; i<n; i++)
			if (clock[i] && cclock[n-1-i])
				cout << ' '<< len-1-locs[n-1-i] << " CCC";
			else if (clock[i])
				cout << ' '<< len-1-locs[n-1-i] << " C";
			else if (cclock[n-1-i])
				cout << ' '<< len-1-locs[n-1-i] << " CC";
		cout << endl;
		
		cin >> len >> n;
	}
	return 0;
}

