#include <bits/stdc++.h>
#define endl "\n"
#define INT long long int

using namespace std;

char infile[100], outfile[100];
char S[10000];
int main() {
    ios::sync_with_stdio(false);
    INT T, n, i,j,A, a,I,p;
    cin >> T;
    for(I=1;I<=T;I++){
        sprintf(infile, ".%d.in", I);
        freopen(infile, "w", stdout);
        
        scanf("%d",&a);
        printf("%d\n",a);        
	    i = 0;
        j = 0;
        A= a;
        while(a%2==0){
            a = a/2;
            i++;
        }
        for(p=3;p*p<=a;p=p+2){
            if(a%p==0) j++;
        }
        if(a>1) j++;
        
		
        sprintf(outfile, ".%d.out", I);
        freopen(outfile, "w", stdout);
        if(A==1){
        	printf("S");
        }
        else if((i>1 and j>0)or(i==1 and j>1) or (i==1 and j==0) or (i==0) ){
            printf("G");
        }else{
            printf("S");
        }
    }
}
