N=gets.to_i E=Array.new(N){[]} N.times{|n| a,b=gets.split.map{|i|i.to_i-1} E[a] << [b,n+1] E[b] << [a,n+1] } Q=[[0,[]]] C=Array.new(N){false} max=[] until Q.empty? n,l=Q.shift #warn [n,l].inspect if C[n] m=C[n]&l max=(C[n]|l)-m break end C[n]=l E[n].each{|nn| next if l[-1]==nn[1] Q<<[nn[0],l+[nn[1]]] } end puts max.size puts max*" "