L = [input(), input()] res = "OK" for i in L: if not i.isdigit() or (i.startswith("0") and len(i)>1): res = "NG" break if not 0 <= int(i) <= 12345: res = "NG" break print(res)