Start = 0
Goal = 1

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

degree = Array.new(101,0)
max = -1
while input = $stdin.gets
  a,b = input.chomp.split(" ").map(&:to_i)
  unless (a|b) == 0
    degree[a - 1] += 1
    degree[b - 1] += 1
    max = a - 1 if a > max
    max = b - 1 if b > max
  else
    puts(solve(degree, max)? "OK" : "NG")
    degree = Array.new(100,0)
    max = -1
  end
end