u=lambda:map(lambda t:ord(t)-0x30,raw_input().strip());v=lambda x:int(''.join(map(str,x)));a=u();b=u();print(all([0<=x<=9 for x in a+b])&((len(a)<2 or a[0]!=0)&(len(b)<2 or b[0]!=0))&(v(a)<12346 and v(b)<12346))and'OK'or'NG'