#include<bits/stdc++.h>
using namespace std;
vector<int>a;
long int sum = 0;
int check()
{
for(int i=0;i<a.size();i++)
{
if((sum - a[i])%3 == 0 && a[i] != 0)
{
sum -= a[i];
a[i] = 0;
return 1;
}
}
return 0;
}
int main()
{
int t, j = 0;
cin >> t;
while(t--)
{
j++;
string s;
cin >> s;
for(int i=0;i<s.size();i++)
{
int p = s[i]-48;
a.push_back(p);
sum += p;
}
int i = 0;
while(check() == 1)
i++;
if(i%2 == 0)
cout << "Case " << j << ": T" << "\n";
else
cout << "Case " << j << ": S" << "\n";
a.clear();
sum = 0;
}
return 0;
}
Comments
Post a Comment