route = Array.new(100,0)
until !(line = gets)  
  frm,to = line.split.map(&:to_i)
  if frm == 0 && to == 0
    route.map!{|x|x%2}
    if route[1] == 0 || route[2] == 0
      puts "NG"
    else
      route[1],route[2] = 0,0
      puts route.include?(1) ?  "NG":"OK" 
    end
  else
    route[frm] +=1 
    route[to] +=1 
  end
end