a=input() b=input() if a.isnumeric() and b.isnumeric(): if int(a) > 12345 or int(b) > 12345: print("NG") elif (a[0]=="0" and a!="0") or (b[0]=="0" and b!="0"): print("NG") else: print("OK") else: print("NG")