# ????£?10??????????????°20???
array = Array.new(100)
50.times do
	a,b = gets.split(' ').map(&:to_i)
	array[a] = array[a] ? array[a] + 1 : 1
	array[b] = array[b] ? array[b] + 1 : 1
	if a==0
		i = 3
		odd=0
		while array[i]
			odd = odd+1 if array[i]%2!=0
			i = i+1
		end
		if odd==0 && array[1]%2==1 && array[2]==1
			puts 'OK'
		else
			puts 'NG'
		end
		array = Array.new(100)
	end

end