class BinaryTree
	class Node
		attr_accessor :parent, :left, :right, :depth, :height

	end

	def initialize
		@nodes = []
	end

	def add(id, left, right)
		@nodes[id] ||= Node.new
		@nodes[id].left  = left
		@nodes[id].right = right

		if left != -1
			@nodes[left] ||= Node.new
			@nodes[left].parent = id
		end

		if right != -1
			@nodes[right] ||= Node.new
			@nodes[right].parent = id
		end
		self
	end

	def description(id)
		node = @nodes[id]
		desc  = "node #{id}: "
		desc += "parent = #{node.parent ? node.parent : -1}, "
		desc += "sibling = #{sibling(id)}, "
		desc += "degree = #{degree(id)}, "
		desc += "depth = #{depth(id)}, "
		desc += "height = #{height(id)}, "
		desc += "#{type(id)}"
	end

	private
	def sibling(id)
		return -1 unless @nodes[id].parent
		parent = @nodes[@nodes[id].parent]
		return parent.left if parent.left && parent.left != id
		return parent.right if parent.right && parent.right != id
		-1
	end

	def degree(id)
		node = @nodes[id]

		degree = 0
		degree += 1 if exist?(node.left)
		degree += 1 if exist?(node.right)

		degree
	end

	def depth(id)
		node = @nodes[id]

		return node.depth if node.depth
		return 0 unless node.parent

		node.depth = depth(node.parent) + 1
	end

	def height(id)
		node = @nodes[id]

		return node.height if node.height
		return 0 if !exist?(node.left) && !exist?(node.right)

		lheight = height(node.left)
		rheight = height(node.right)
		node.height = (lheight >= rheight ? lheight : rheight) + 1
	end

	def type(id)
		node = @nodes[id]
		return "root" unless node.parent
		return "internal node" if exist?(node.left) || exist?(node.right)
		"leaf"
	end

	def exist?(id)
		id && id != -1
	end

end

tree = BinaryTree.new
n = STDIN.gets.to_i
n.times do
	id, left, right = STDIN.gets.split[0..2].map(&:to_i)
	tree.add(id, left, right)
end

n.times { |i| puts tree.description(i) }