#include <cstdio>
#include <iostream>
#include<cstring>
using namespace std;
int main() {
char a[10],b[10];
int i,j;
long long asum=1,bsum=1;
cin>>a;
cin>>b;
for(i=0;i<strlen(a);i++){
asum*=a[i]-'A'+1;}
for(i=0;i<strlen(b);i++){
bsum*=b[i]-'A'+1;
}
if((asum%47)==(bsum%47))
cout<<"GO";
else
cout<<"STAY";
return 0;
}