table = []
readlines.each do |l|
  i,j = l.split.map(&:to_i)
  if i==0 && j==0
    if table.map{|i| i ? i.count{|j| j==1} : 0 }.inject(:+).even?
      puts "OK"
    else
      puts "NG"
    end
    table = []
  else
    table[i] ||= []
    table[i][j] = 1
  end
end