class TreeNode

	attr_accessor :id, :parent, :children

	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 merge(other)
		if @id == other.id
			@children = other.children.map { |c| c.parent = self; c }
			return self
		end

		result = false
		@children.each do |c|
			result = !!c.merge(other)
			break if result
		end
		result ? self : nil
	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 depth
		return 0 unless @parent
		@parent.depth + 1
	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 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
input_id_list = []
trees = []

n.times do
	id, degree, *children = STDIN.gets.split.map(&:to_i)
	input_id_list << id

	merged = false
	tree = TreeNode.new(id).add_children(*children[0...degree])
	trees.reverse_each do |t|
		merged = !!t.merge(tree)
		break if merged
	end

	trees << tree unless merged
end

tree = trees.reverse!.shift
until trees.empty?
	tmp = trees.shift
	merged = !!tree.merge(tmp)
	unless merged
		trees << tree
		tree = tmp
	end
end

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