/*
TASK:roulette
LANG:C++
*/

# include <stdio.h>
# include <string.h>
# define MAXN (1<<15)	// 2^15 > (5^6)^2


struct state{
	char left[7];		// cards left from certain type (left[0]-numer of 1's left)
	char p;				// Who's turn is. 0- Gosho 1-Tosho
};

bool calc[MAXN];		// is the situation calculated
bool win[MAXN];			// is this possituan winnable.
int move[MAXN];			// stores the win move

char str[128];
int l;

// Code produses a int code from the possition.
int code(state st) {
	int res=0;
	for ( int i=0 ; i<6 ; i++ )
		res = res*5+st.left[i];
	res = res*2+st.p;
	return res;
}
// Decode produses the possition from a int code.
state decode(int x) {
	state st;
	st.p = x%2;
	x/=2;
	for ( int i=5 ; i>=0 ; i-- ) {
		st.left[i] = x%5;
		x/=5;
	}
	return st;
}
// Calculate if possition x with current sum from the card in the flore - sum
void sl(int x, int sum) {
	if ( calc[x]==1 ) return;
	state cur = decode(x);
	for ( int i=0 ; i<6 ; i++ ) {
		if ( cur.left[i]!=0 && i+1+sum<=49 ) {
			cur.left[i]--;
			cur.p = !cur.p;
			int y = code(cur);
			sl(y,sum+i+1);
			if ( win[y]==0 ) {
				win[x] = 1;
				move[x] = i+1;
			}
			cur.p = !cur.p;
			cur.left[i]++;			
		}
	}
	calc[x] = 1;
}

void solve() {
	state cur;
	// Init
	int sum=0;
	for ( int i=0 ; i<6 ; i++ ) cur.left[i] = 4;
	cur.p = 0;
	// Initialization of the game
	for ( int i=0 ; i<l ; i++ ) {
		cur.left[str[i]-'1']--;
		cur.p = !cur.p;
		sum+=str[i]-'0';
	}
	int x = code(cur);
	sl(x,sum);
	if ( win[x] ) {
		if ( cur.p ) {
			printf("T %d\n",move[x]);
		} else {
			printf("G %d\n",move[x]);
		}
	} else {
		if ( cur.p ) {
			printf("G %d\n",move[x]);
		} else {
			printf("T %d\n",move[x]);
		}
	}
}

int main() {
	//freopen("roulette.in","r",stdin);
	scanf("%s",str);
	l = (int)strlen(str);
	solve();
	return 0;
}