#include<bits/stdc++.h>
//#include<cxk.h>
#define int long long
#define LL long long
#define FOR(i,l,r) for(int i=(l);i<=(r);i++)
using namespace std;
const int MOD=47;
int a[1001];
signed main()
{
a['A']=1;
a['B']=2;
a['C']=3;
a['D']=4;
a['E']=5;
a['F']=6;
a['G']=7;
a['H']=8;
a['I']=9;
a['J']=10;
a['K']=11;
a['L']=12;
a['M']=13;
a['N']=14;
a['O']=15;
a['P']=16;
a['Q']=17;
a['R']=18;
a['S']=19;
a['T']=20;
a['U']=21;
a['V']=22;
a['W']=23;
a['X']=24;
a['Y']=25;
a['Z']=26;
char str[1000],b[1000];
cin>>str>>b;
int strs=1,bs=1;
FOR(i,0,strlen(str)-1)
{
strs*=a[str[i]];
}
FOR(i,0,strlen(b)-1)
{
bs*=a[b[i]];
}
if(bs%MOD==strs%MOD)
{
cout<"GO";
}
else
{
cout<<"STAY";
}
return 0;
}
//在devc++上能运行,在洛谷上就不能?谁能帮我看看