q=Array.new n=gets.to_i
g=$<.map{|l|i,k,*c=l.split.map &:to_i
c.map{|j|q[j]=i}
[i,c]}.sort
d=->f,i,x{g[i][2]=x
g[i][1].map{|j|f[f,j,x+1]}}
d[d,q.index(p),0]
g.map{|v|i,c,d=v
[i,p=q[i]||-1,d,p<0?:root:c[0]?"internal node": :leaf,c]}.map{|v|puts"node %d: parent = %d, depth = %d, %s, %s"%v}