c=[*0...gets.to_i]
d=$<.map{|l|a,_,*b=l.split.map &:to_i;c-=b;[a,b]}.sort
f=->n,e,a{t=d[n][1].map{|i|f[i,e+1,n]};d[n][1,0]=[a,e,a<0?:root:t==[]?:leaf:"internal node"]}
c.map{|i|f[i,0,-1]}
d.map{|i|puts"node %d: parent = %d, depth = %d, %s, %s"%i}