#include <iostream>

using namespace std;

struct num {
	int y[6];
} x[15504];

int main() {
	int count = 0;
	for(int i=0; i<=15; i++) {
	for(int j=0; j<=15-i; j++) {
	for(int k=0; k<=15-i-j; k++) {
	for(int l=0; l<=15-i-j-k; l++) {
	for(int m=0; m<=15-i-j-k-l; m++) {
		int n = 15-i-j-k-l-m;
		x[count].y[0] = i;
		x[count].y[1] = j;
		x[count].y[2] = k;
		x[count].y[3] = l;
		x[count].y[4] = m;
		x[count].y[5] = n;
		count++;
	}}}}}

	char n;
	int num, array[6];
	int casenum = 1;
	cin >> n;
	while(n != 'e') {
		if(n == 'u') {
			cin >> num;
			cout << "Case " << casenum << ":";
			for(int i=0; i<6; i++) {
				cout << " " << x[num].y[i];
			}
			cout << endl;
		}
		else {
			for(int i=0; i<6; i++) {
				cin >> array[i];
			}
			cout << "Case " << casenum << ":";
			int index = 0;
			for(int i=0; i<6; i++) {
				while(x[index].y[i] != array[i]) {
					index++;
				}
			}
			cout << " " << index << endl;
			// do nothing for now
		}
		casenum++;
		cin >> n;
	}
}