program ride;
var
s:string[6];
a,b,c:longint;
begin
assign(input,'ride.in');
reset(input);
assign(output,'ride.out');
rewrite(output);
readln(s);
b:=1;
c:=1;
for a:=1 to length(s) do begin
b:=b * (ord(s[a]) - 64);
end;
readln(s);
for a:=1 to length(s) do begin
c:=c * (ord(s[a]) - 64);
end;
if (c mod 47) =(b mod 47) then
writeln('GO')
else
writeln('STAY');
close(input);
close(output);
end.