#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef tuple<int,int,int,int,int,int> tii;

map<tii,int> M;
vector<tii> v; 
int main(){
    ios::sync_with_stdio(0);
    for (int a=0;a<=15;a++) for (int b=0;b<=15;b++) for (int c=0;c<=15;c++) for (int d=0;d<=15;d++) for (int e=0;e<=15;e++){
        int f=15-a-b-c-d-e;
        if ((0<=f)&&(f<=15)) v.push_back(make_tuple(a,b,c,d,e,f));
    }
    for (int i=0;i<v.size();i++) M[v[i]]=i;
    char t; int ca=1;
    while (cin>>t){
        if (t=='e') break;
        cout<<"Case "<<ca<<":";
        if (t=='m'){
            int a,b,c,d,e,f; cin>>a>>b>>c>>d>>e>>f;
            cout<<" "<<M[make_tuple(a,b,c,d,e,f)]<<endl;
        }
        if (t=='u'){
            int x; cin>>x;
            cout<<' '<<get<0>(v[x])<<' '<<get<1>(v[x])<<' '<<get<2>(v[x])<<' '<<get<3>(v[x])<<' ';
            cout<<get<4>(v[x])<<' '<<get<5>(v[x])<<endl;
        }
        ca++;
    }
    return 0;
}