q=Array.new n=gets.to_i,M=-1
s=*q
g=$<.map{|l|i,*c=l.split.map &:to_i
!i&&next
c.reject!{|v|v<0}
c.map{|j|q[j]=i}
c[1]&&(a,b=c
s[a],s[b]=b,a)
[i,c]}.compact.sort
d=->f,i,x{g[i][2]=x
g[i][3]=(g[i][1].map{|j|f[f,j,x+1]}.max||M)+1}
d[d,q.index(M),0]
g.map{|v|i,c,d,h=v
[i,p=q[i],s[i],c.size,d,h,p<0?:root:c[0]?"internal node": :leaf]}.map{|v|puts ["node %d: parent",:sibling,:degree,:depth,:height,"%s"]*" = %d, "%v}