#include <fstream>
#include <iostream>
#include <string>
using namespace std;
string fd, tt;
unsigned long long a = 1, b = 1;
main()
{
ifstream fin("ride.in");
ofstream fout("ride.out");
//#define fin cin
//#define fout cout
fin >> fd >> tt;
for (int i = 0; i < fd.size(); ++i)
a = a * (fd[i] - 'A' + 1) % 47;
for (int i = 0; i < tt.size(); ++i)
b = b * (tt[i] - 'A' + 1) % 47;
if (a == b)
fout << "GO";
else
fout << "STAY";
}