def isOK(s):
    if s=="0" or (s.isdecimal() and s[0]!='0'):
        return 0<=int(s)<=12345
    else:
        return False
   
    
    
A=input()
B=input()
if isOK(A) and isOK(B):
    print('OK')
    
else:
    print('NG')