content: package v114;
  import java.io.BufferedReader;
  import java.io.FileReader;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.io.PrintWriter;
  import java.util.StringTokenizer;
  
  
  public class IntegerGame_UVa11489 {
  
  	public static void main(String[] args) throws IOException 
  	{
  		Scanner sc = new Scanner(System.in);
  		PrintWriter out = new PrintWriter(System.out);
  	
  		int tc = sc.nextInt();
  		for(int t = 1; t <= tc; ++t)
  		{
  			char[] s = sc.next().toCharArray();
  			out.printf("Case %d: ", t);
  			int count = 0, sum = 0;
  			for(char c: s)
  			{
  				if(c == '3' || c == '9' || c == '6')
  					++count;
  				sum += c - '0';
  			}
  			if(sum%3 == 0)
  				out.println(count%2 == 0 ? "T" : "S");
  			else
  			{
  				boolean can = false;
  				for(char c: s)
  					if((sum - c + '0')%3 == 0) { can = true; break; }
  				out.println(can && count%2 == 0 ? "S" : "T");
  			}
  		}
  		out.flush();
  		out.close();
  	}
  	
  	static class Scanner 
  	{
  		StringTokenizer st;
  		BufferedReader br;
  
  		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}
  
  		public Scanner(FileReader r){	br = new BufferedReader(r);}
  
  		public String next() throws IOException 
  		{
  			while (st == null || !st.hasMoreTokens()) 
  				st = new StringTokenizer(br.readLine());
  			return st.nextToken();
  		}
  
  		public int nextInt() throws IOException {return Integer.parseInt(next());}
  
  		public long nextLong() throws IOException {return Long.parseLong(next());}
  
  		public String nextLine() throws IOException {return br.readLine();}
  
  		public double nextDouble() throws IOException { return Double.parseDouble(next()); }
  
  		public boolean ready() throws IOException {return br.ready();}
  
  		public boolean hasNext() throws IOException
  		{
  			while(br.ready() && (st == null || !st.hasMoreTokens()))
  				st = new StringTokenizer(br.readLine());
  			return st.hasMoreTokens();
  		}
  
  
  	}
  }