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