Start = 0
Goal = 1

def solve degree, max
  if degree[Start] % 2 == 1 && degree[Goal] % 2 == 1
    2.upto(max) do |i|
      return false if degree[i] % 2 == 1
    end
    true
  else
    false
  end
end



while true do
  table = []
  list = []
  while true do
    a, b = gets.split.map(&:to_i)
    break if !a || a.zero? && b.zero?
    list << [a, b]
  end 

  break if list == []

  table = Array.new(list.flatten.max.succ, 0)

  list.each do|a, b|
    table[a] += 1
    table[b] += 1

  end
  table.shift
  puts solve(table,list.flatten.max - 1) ? :OK : :NG


end