#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
	int a,b,c=1,d=1,h,i,y,z,num1[6],num2[6];
	string name1,name2;
	ifstream OpenFile("ride.in");
	OpenFile>>name1;
	OpenFile>>name2;
	OpenFile.close();
	for(y=0;y<6;y++)
	{
		if(name1[y]!='\n'&&name1[y]!=0)num1[y]=name1[y]-64;
	}
	for(z=0;z<6;z++)
	{
		if(name2[z]!='\n'&&name2[z]!=0)num2[z]=name2[z]-64;
	}
	for(a=0;a<6;a++)
	{
		if(num1[a]!=0)c*=num1[a];
	}
	for(b=0;b<6;b++)
	{
		if(num2[b]!=0)d*=num2[b];
	}
	h=c%47;
	i=d%47;
	ofstream SaveFile("ride.out");
	if(h==i)
	{
		SaveFile<<"GO"<<endl;
	}
	else
	{
		SaveFile<<"STAY"<<endl;
	}
	cout<<endl;
	SaveFile.close();
	return 0;
}