def f n,e
return 0 if e.include?(n)
$h[n].map{|a|f(a,e+[n])}||0
end
while(n=gets.to_i)>0
$h=([0]*101).map{[]}
n.times{a,b=gets.split.map(&:to_i);exit if a>100||b>100;$h[a]<<b;$h[b]<<a}
p (1..100).map{|i|f i,[]}
end