# 左子右兄弟表現(一番左の子と、自分の右隣の兄弟へのリンクを持つ)
class TreeNode
	attr_accessor :parent, :left_child, :right_sibling, :depth

	def type
		return "root" unless @parent
		return "leaf" unless @left_child
		"internal node"
	end

	def self.set_depth(nodes, id, depth)
		nodes[id].depth = depth
		if nodes[id].right_sibling
			set_depth(nodes, nodes[id].right_sibling, depth)
		end
		if nodes[id].left_child
			set_depth(nodes, nodes[id].left_child, depth + 1)
		end
	end

	def self.description(nodes, id)
		node = nodes[id]
		children_id_list = []

		child_id = node.left_child
		while child_id
			children_id_list << child_id
			child_id = nodes[child_id].right_sibling
		end

		desc  = "node #{id}: "
		desc += "parent = #{node.parent ? node.parent : -1}, "
		desc += "depth = #{node.depth}, "
		desc += "#{node.type}, "
		desc += "[#{children_id_list.join(", ")}]"
	end
end

# 木全体を配列で管理する, indexがidと紐づく
n = STDIN.gets.to_i
nodes = []
n.times { nodes << TreeNode.new }

n.times.each do |i|
	id, degree, *children = STDIN.gets.split.map(&:to_i)

	prev = nil
	children[0...degree].each_index do |j|
		child = children[j]

		if j == 0
			nodes[id].left_child = child
		else
			nodes[prev].right_sibling = child
		end

		prev = child
		nodes[child].parent = id
	end
end

root = nodes.find_index { |node| node.parent == nil }
TreeNode.set_depth(nodes, root, 0)
nodes.each_index { |id| puts TreeNode.description(nodes, id) }