#include <bits/stdc++.h>

using namespace std;
int A, B, C, D;

bool nt(int x)
{
    if (x < 2) return false;
    for (int i=2; i*i<=x; i++)
        if (x % i == 0) return false;
    return true;
}
string winer(int A, int B, int C, int D)
{
    for (int x = A; x <= B; x++)
    {
        bool ok = true;
        for (int y = C; y <= D; y++)
            if (nt(x+y))
            {
                ok = false;
                break;
            }
        if (ok) return "Tam";
    }
    return "Cam";
}
int main()
{
    freopen("game.inp","r",stdin);
    freopen("game.out","w",stdout);
    int test;
    cin >> test;
    while (test--)
    {
        cin >> A >> B >> C >> D;
        cout << winer(A,B,C,D) << "\n";
    }
    return 0;
}
