A = gets.rstrip B = gets.rstrip ans = if A == '0' || B == '0' || ( A =~ /^[1-9]+\d*$/ && B =~ /^[1-9]+\d*$/ && 0 <= A.to_i && A.to_i <= 12345 && 0 <= B.to_i && B.to_i <= 12345) 'OK' else 'NG' end puts ans