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"
    elsif
      node[1] % 2 == 0 && node[2] % 2 == 0
      puts "NG"
    else
      cnt = 0
      node.each{|h, k|
        cnt += 1 if k % 2 == 1
      }
      if cnt == 2
        puts "OK"
      else
        puts "NG"
      end
    end
    node = {}
    next
  end
  node[s] ||= 0
  node[t] ||= 0
  node[s] += 1
  node[t] += 1
}