#include<iostream>
#include<string>
#include<fstream>
using namespace std;
int main()
{
string ufo,teme;
int sum,sum1;
ifstream cin("in.txt");
while(cin>>ufo>>teme)
{
sum = 1;
sum1 = 1;
for(int i=0;i < ufo.size();i++)
{
sum *= (ufo[i]-64);
}
for(int i=0;i < teme.size();i++)
{
sum1 *= (teme[i]-64);
}
if(sum%47 == sum1 % 47)
cout<<"GO"<<endl;
else
cout<<"STAY"<<endl;
}
}