import sys input=lambda: sys.stdin.readline().rstrip() N=[str(i) for i in range(10)] def chk(x): ret=True for xx in x: if xx not in N: ret=False if x[0]=="0" and len(x)>1: ret=False if ret and int(x)>12345: ret=False return ret a=chk(input()) b=chk(input()) print("OK" if a and b else "NG")