class BinaryTree
	attr_accessor :parent, :left, :right
	def format(id)
		puts "node #{id}: parent = #{self.parent}, sibling = #{self.get_sibling(id)}, degree = #{self.get_degree}, depth = #{self.get_depth}, height = #{self.get_height(id)}, #{self.get_type}"
	end
	
	def initialize(parent = -1, left = -1, right = -1)
		@parent = parent
		@left = left
		@right = right
	end
	
	def get_sibling(id)
		parent_node = $nodes[self.parent]
		result = parent_node.left == id ? parent_node.right : parent_node.left
		return result
	end
	
	def get_degree
		cnt = 0
		cnt += 1 if self.left != -1
		cnt += 1 if self.right != -1
		return cnt
	end
	
	def get_type
		if self.parent == -1
			return "root"
		else
			if self.left == -1 && self.right == -1
				return "leaf"
			else
				return "internal node"
			end
		end
	end
	

	def get_height(id,h=0)
		return h if $nodes[id].left == -1 && $nodes[id].right == -1
		h1 = $nodes[id].left != -1 ? get_height($nodes[id].left, h+1) : 0
		h2 = $nodes[id].right != -1 ? get_height($nodes[id].right, h+1) : 0
		return [h1, h2].max
	end
	
	def get_depth
		depth = 0
		i = self.parent
		while true
			return depth if i == -1
			i = $nodes[i].parent
			depth += 1
		end
	end
end


n = gets.chomp.to_i
$nodes = []
n.times do |i|
	$nodes[i] = BinaryTree.new
end

n.times do
	id, left, right = gets.chomp.split(" ").map{|i|i.to_i}
	if left != -1
		$nodes[id].left = left
		$nodes[left].parent = id
	end
	if right != -1
		$nodes[id].right = right if right != -1
		$nodes[right].parent = id
	end
end

$nodes.each_with_index do |node,ix|
	node.format(ix)
end
