A, B = gets.chomp, gets.chomp MAXIMUM_VALUE = 12_345 if A =~ /[^\d]/ || B =~ /[^\d]/ puts 'NG' exit end if A =~ /^0+[^0]+/ || B =~ /^0+[^0]+/ || [A.to_i, B.to_i].find { |n| n > MAXIMUM_VALUE } puts 'NG' exit end puts 'OK'