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