
while true
	array = []
	while true
		line = gets.chomp
		exit if line.nil?
		a,b = line.split(' ').map(&:to_i)
		array[a] = array[a] ? array[a] + 1 : 1
		array[b] = array[b] ? array[b] + 1 : 1
		if a==0 && b==0
			i = 3
			status = array[1]%2==1 && array[2]==1 ? 'OK' : 'NG'
			#p "now #{status}, #{array[1]} #{array[2]}"
			while array[i]
				if array[i]%2!=0
					status = 'NG'
					break
				end
				i = i+1
			end
		end
	end
	puts status
end