ns = Hash.new 0
$<.each_line do |l|
  a, b = l.split.map(&:to_i)
  if a.zero? and b.zero?
    puts ns.each_value.count(&:odd?) == 2 && ns[1].odd? && ns[2].odd? ? 'OK' : 'NG'
    ns.clear
    next
  end
  ns[a] += 1
  ns[b] += 1
end