#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, a,I;
    cin >> T;
    for(I=21;I<=20+T;I++){
        sprintf(infile, ".%d.in", I);
        freopen(infile, "w", stdout);
        scanf("%d",&n);
        printf("%d\n",n);        
	    int s = 0;
        int k = 1;
        for(i=0;i<n;i++){
        	//a = rand()%2+1;
            scanf("%d", &a);
            printf("%d ",a);
            if(a == 1 and k==1){
                s++;
            }else if(k==1){
                s++;
                k = 0;
            }
        }
		
        sprintf(outfile, ".%d.out", I);
        freopen(outfile, "w", stdout);
        if(s%2==1) printf("G");
        else printf("S");
    }
}
