#include<bits/stdc++.h>
using namespace std;
char c;
int a=1,b=1;
int main()
{
while((c=getchar())!='\n') a*=c-'a'+1;
while((c=getchar())!='\n') b*=c-'a'+1;
a%=47;
b%=47;
if (a==b) cout <<"GO"<<endl;
else cout <<"STAY"<<endl;
cout <<a<<b<<endl;
return 0;
}