class TreeNode

	attr_reader :id

	def initialize(id, parent=nil)
		@id = id
		@parent = parent
		@children = []
	end

	def add_children(*id_list)
		id_list.each { |id| @children << TreeNode.new(id, self) }
		self
	end

	def add_children_to_specified_id(id, *id_list)
		return !!add_children(*id_list) if id == @id
		is_added = false
		@children.each do |c|
			is_added = c.add_children_to_specified_id(id, *id_list)
			break if is_added
		end
		is_added
	end

	def get_node(id)
		return self if id == @id
		result = nil
		@children.each do |c|
			result = c.get_node(id)
			break if result
		end
		result
	end

	def type
		return "root" unless @parent
		return "internal node" unless @children.empty?
		"leaf"
	end

	def children_id_list
		@children.map { |c| c.id }
	end

	def depth
		return 0 unless @parent
		@parent.depth + 1
	end

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

end

n = STDIN.gets.to_i
f_id, f_degree, *f_id_list = STDIN.gets.split.map(&:to_i) # 最初の一行目はルートなので先に処理する

input_id_list = [f_id]
tree = TreeNode.new(f_id).add_children(*(f_id_list[0...f_degree]))

(n - 1).times do
	id, degree, *id_list = STDIN.gets.split.map(&:to_i)
	input_id_list << id
	tree.add_children_to_specified_id(id, *(id_list[0...degree]))
end

input_id_list.sort!.each { |id| puts tree.get_node(id) }