#include<bits/stdc++.h>
using namespace std;
int main()
{
char z[1000],c[1000];
gets(z);
gets(c);
int a,b,e=1,d=1;
a=strlen(z);
b=strlen(c);
for(int i=1; i<=a; ++i)
{
e*=z[i-1]-64;
e%=47;
}
for(int i=1; i<=b; ++i)
{
d*=c[i-1]-64;
d%=47;
}
if(e==d) cout<<"GO";
else cout<<"STAY";
return 0;
}
by c1806xiaoyang @ 2019-10-19 11:31:40