c=lambda x:all(i in"0123456789"for i in x)and[1,x[0]!="0"][1!=len(x)]and 0<=int(x)<=12345 print(["NG","OK"][c(input())and c(input())])