g=(0...gets.to_i).map{gets.split.map &:to_i}
g.map{|v|i,k,*c=v
j,*a=i
0until g.map{|w|a<<j=w[0]if w[2,$$].index j}.all? &:!
[i,p=a[0]||-1,a.size,p<0?:root:c[0]?"internal node": :leaf,c]}.sort.map{|v|puts"node %d: parent = %d, depth = %d, %s, %s"%v}