#include<bits/stdc++.h>
using namespace std;
int main(){
char a[110000],b[110000],x=1,y=1;
cin>>a;
cin>>b;
for(int i=1;i<=strlen(a);i++){
x*=a[i]-'@';
}
for(int j=1;j<=strlen(b);j++){
y*=b[j]-'@';
}
if(x%47==y%47){
cout<<"GO";
}
else{
cout<<"STAY";
}
return 0;
}