#include<bits/stdc++.h>
using namespace std;
string a,b;
long long s=1,S=1;
int main(){
cin>>a>>b;
for(int i=0; i<a.length(); i++)
s*=a[i]-'@';
for(int i=0; i<b.length(); i++)
S*=a[i]-'@';
s%=47;
S%=47;
if(s==S){
cout<<"GO";
return 0;
}
cout<<"STAY";
return 0;
}