a = gets.chomp b = gets.chomp puts [a,b].all?{|x| x.split.all?{|c| c =~ /\d/} && x.to_i.to_s == x && x.to_i <= 12345} ? 'OK' : 'NG'