#include<bits/stdc++.h>
using namespace std;
long long T,n;
int main(){
cin>>T;
while(T--){
cin>>n;
set<long long> st;
bool S_bool=true,G_bool=true,H_bool=true;
long long temp=n;
while(temp!=0){
st.insert(temp%10);
temp/=10;
}
for(auto it=st.begin();it!=st.end();it++){
if((*it)==0 || n%(*it)==0){
S_bool=false;
}else if(n%(*it)!=0){
G_bool=false;
}
}
if(S_bool==true){
cout<<"S"<<endl;
}else if(G_bool==true){
cout<<"G"<<endl;
}else{
cout<<"H"<<endl;
}
}
return 0;
}

京公网安备 11010502036488号