c=[p]*gets.to_i
d=$<.map{|l|a,_,*b=l.split.map &:to_i;[a,b.map{|i|c[i]=i}]}.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.index(p),0,-1]
d.map{|i|puts"node %d: parent = %d, depth = %d, %s, %s"%i}