n = raw_input() m = raw_input() if n.isdigit() == True and m.isdigit() == True: if int(n) >= 0 and int(n) <= 12345 and int(m) >= 0 and int(m) <= 12345: if len(str(n)) > 1 or len(str(m)) > 1: if n.startswith("0") == True and len(str(n)) > 1: print "NG" elif m.startswith("0") == True and len(str(m)) > 1: print "NG" else: print "OK" else: print "OK" else: print "NG" else: print "NG"