node = {}
readlines.map(&:chomp).each{|line|
  s, t = line.split.map(&:to_i)
  if s == 0 && t == 0
    cnt = 0
    node.each{|h, k|
      cnt += 1 if k.size % 2 == 1
    }
    if cnt == 0 || (cnt == 2 && node[1].size % 2 == 1 && node[2].size % 2 == 1)
      puts "OK"
    else
      puts "NG"
    end
    node = {}
  end
  node[s] ||= []
  node[t] ||= []
  node[s] << t
  node[t] << s
}