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