c=[p]*gets.to_i
l=$<.map{|t|n,*a=t.split.map &:to_i;[n,a.select{|i|i>=0&&c[i]=[i,n]+(a-[i])}]}.sort
f=->n,d{c[n][3,0]=[l[n][1].size,d,h=(l[n][1].map{|i|f[i,d+1]}.max||-1)+1,d<1?:root:h<1?:leaf:"internal node"];h}
c[n=c.index(p)]=[n,-1,-1]
f[n,0]
puts c.map{|i|%w(node\ %d:\ parent sibling degree depth height %s)*" = %d, "%i}