while true
  pts = []

  while true
    line = gets
    exit if line.nil?

    p0, p1 = line.chomp.split(" ").map{|s| s.to_i}
    break if p0 == 0 && p1 == 0

    p0 -= 1
    p1 -= 1

    pts[p0] = pts[p0].nil? ? 1 : (pts[p0] + 1)
    pts[p1] = pts[p1].nil? ? 1 : (pts[p1] + 1)
  end
  #p pts

  ok = true

  if pts[0] % 2 == 0 || pts[1] % 2 == 0
    ok = false
  else
    for i in (2...pts.length)
      if pts[i] % 2 != 0
        ok = false
        break
      end
    end
  end

  puts ok ? "OK" : "NG"
end