route = Array.new(100,0)
readlines.each do |line|
  frm,to = line.split.map(&:to_i)
  if frm == 0 && to == 0
    if route[1].odd? && route[2].odd? && route.drop(3).all?(&:even?)
      puts"OK" 
    else
      puts"NG"
    end
    route = Array.new(100){0}
  else
    route[frm] +=1 
    route[to] +=1 
  end
end