MAX = 100005

class Node
	attr_accessor :p, :l, :r
	def initialize(p, l, r)
		@p = p; @l = l; @r = r
	end
end

$t = []
#$d = []

def my_print(u)
	if $t[u].p == nil
		#print("node ", u, ": parent = -1, depth = ", $d[u], ", ")
		print("node ", u, ": parent = -1, depth = ", getDepth(u), ", ")
	else
		print("node ", u, ": parent = ", $t[u].p, ", depth = ", getDepth(u), ", ")
	end
	if $t[u].p == nil
		print("root, ")
	elsif $t[u].l == nil
		print("leaf, ")
	else
		print("internal node, ")
	end
	print("[")
	i = 0
	c = $t[u].l
	while c != nil
		print(", ") if i > 0
		print c
		i += 1
		c = $t[c].r
	end
	print("]\n")
end

def getDepth(u)
	d = 0
	while $t[u].p != nil
		u = $t[u].p
		d += 1
	end
	return d
end

def rec(u, p)
	$d[u] = p
	rec($t[u].r, p) if $t[u].r != nil
	rec($t[u].l, p + 1) if $t[u].l != nil
end

n = gets.to_i
for i in 0...n do
	$t[i] = Node.new(nil, nil, nil)
end
for i in 0...n do
	line = gets.split.map &:to_i
	v, d = line.shift, line.shift
	l = 0
	for j in 0...line.size do
		if j == 0
			$t[v].l = line[j]
		else
			$t[l].r = line[j]
		end
		l = line[j]
		$t[line[j]].p = v
	end
end
for i in 0...n do
	r = i if $t[i].p == nil
end

#rec(r, 0)

for i in 0...n do
	my_print(i)
end