#define rep(i, a, n) for (int i = a; i < n; ++i) #define per(i, a, n) for (int i = n - 1; i >= a; --i) #define fi first #define se second #define pb push_back #define mp make_pair #define np next_permutation #define INF 0x3f3f3f3f #define EPS 1e-8 #define endl '\n' string a, b; constint mod = 47; constint maxn = 1e5 + 5;
intmain() { ios::sync_with_stdio(false); while (cin >> a >> b) { int ans = 1, ans2 = 1; rep(i, 0, a.length()) { ans = (ans * (a[i] - 'A' + 1)) % mod; } rep(i, 0, b.length()) { ans2 = (ans2 * (b[i] - 'A' + 1)) % mod; } if (ans == ans2) cout << "GO" << endl; else cout << "STAY" << endl; } }