node = {}
readlines.map(&:chomp).each{|line|
  s, t = line.split.map(&:to_i)
  if s == 0 && t == 0
    if node[1] % 2 != node[2] % 2
      puts "NG"
    else
      node.delete(1)
      node.delete(2)
      cnt = 0

      node.each{|h, k|
        cnt += 1 if k % 2 == 1
      }
      if cnt == 0
        puts "OK"
      else
        puts "NG"
      end
    end
    node = {}
    next
  end
  node[s] ||= 0
  node[t] ||= 0
  node[s] += 1
  node[t] += 1
}