#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char buf[10];
    scanf("%s", buf);
    int a = 1;
    for (char *p = buf; *p; p++)
        a = a * (*p - 'A' + 1) % 47;
    scanf("%s", buf);
    int b = 1;
    for (char *p = buf; *p; p++)
        b = b * (*p - 'A' + 1) % 47;
    puts(a == b ? "GO" : "STAY");
    return 0;
}
