i=input a=i() b=i() for i in a: if not i.isdigit(): print('NG'); exit() for i in b: if not i.isdigit(): print('NG'); exit() if 0 <= int(a) <= 12345 and (int(a) == 0 or a[0] != '0') and 0 <= int(b) <= 12345 and (int(b) == 0 or b[0] != '0'): print('OK') else: print('NG')