STDERR.print "Number of nodes? "
V = gets.to_i

STDERR.print "Directed (u/d)? "
D = (gets.chomp.downcase=="d");

ES = []
loop do
	STDERR.print "Edge (u v)? "
	edge = gets.split.map(&:to_i)
	break if edge.size==0
	ES << edge
end

V.times do |y|
	puts (0...V).map{|x|
		(D ? ES.index([y,x]) : ES.index([y,x]) || ES.index([x,y])) ? "Y" : "N"
	}*""
end
