/*
ID: boyshan1
PROG: ride
LANG: C++
*/
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
ofstream fout ("ride.out");
ifstream fin ("ride.in");
string a,b;
int m=1,n=1;
while(fin>>a>>b)
{
char *p,*q;
for(p=&a[0];*p!='\0';p++)
m=m*(int)(*p-64);
for(q=&b[0];*q!='\0';q++)
n=n*(int)(*q-64);
if(m%47==n%47)
fout<<"GO"<<endl;
else fout<<"STAY"<<endl;
}
return 0;
}