a, b = gets, gets if a =~ /[a-zA-z]/ || b =~ /[a-zA-Z]/ then puts "NG" elsif a =~ /^0[0-9]+/ || b =~ /^0[0-9]+/ then puts "NG" else a = a.to_i b = b.to_i if a > 12345 || b > 12345 then puts "NG" else puts "OK" end end