
class Tree
	attr_accessor :parent, :root
	def initialize()
		@parent = -1
		@root = []
	end

	def depth
		ans = 0
		if @parent!=-1
			ans+=1
			ans += @parent.depth
		end
		ans
	end

	def add(data)
		@root << data
	end
end



n = gets.to_i
tree = Hash.new
n.times do |i|
	tree[i] = Tree.new()
end

n.times do |i|
	data = gets.split.map(&:to_i)
	num = data.shift
	data.shift
	
	data.each do |obj|
		tree[num].add(obj)
		tree[obj].parent = tree[num]
	end
end
 num = 0
 n.times do |i|
    obj = tree[i]
	jd = nil
	if obj.parent ==-1
		jd = "root"
	elsif obj.root.empty?
		jd = "leaf"
	else 
		jd = "internal node"
	end

	puts "node #{num}: parent = #{tree.key(obj.parent)||-1}, depth = #{obj.depth}, #{jd}, [#{obj.root.join(", ")}]"
	num+=1
end