#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 1005;
char s[maxn];
int T, n;
int main() {
//freopen("out.txt", "w", stdout);
scanf("%d", &T);
for (int kase = 1; kase <= T; kase++) {
cin >> s;
n = strlen(s);
if (n == 1) {
printf("Case %d: S\n", kase);
continue;
}
int sum = 0, cnt = 0;
for (int i = 0; i < n; i++) {
sum += s[i]-'0';
if ((s[i]-'0') % 3 == 0) cnt++;
}
if (sum % 3 == 0) {
if (cnt % 2 == 0) printf("Case %d: T\n", kase);
else printf("Case %d: S\n", kase);
continue;
}
else {
bool ok = false;
for (int i = 0; i < n; i++) {
if ((sum-s[i]+'0') % 3 == 0) { ok = true; break; }
}
if (!ok) {
printf("Case %d: T\n", kase);
continue;
}
else {
if (cnt % 2 == 0) printf("Case %d: S\n", kase);
else printf("Case %d: T\n", kase);
continue;
}
}
}
return 0;
}