MAX = 100005
NONE = -1

class Node
	attr_accessor :p, :l, :r
	def initialize(p, l, r)
		@p = p; @l = l; @r = r
	end
end

$t = []
#$d = []
$h = []

def my_print(u)
	if $t[u].p == NONE
		print("node ", u, ": parent = -1, sibling = ", getSibling(u), ", ")
	else
		print("node ", u, ": parent = ", $t[u].p, ", sibling = ", getSibling(u), ", ")
	end
	deg = 0
	deg += 1 if $t[u].l != NONE
	deg += 1 if $t[u].r != NONE
	print("degree = ", deg, ", ")
	print("depth = ", getDepth(u), ", ")
	print("height = ", $h[u], ", ")
	if $t[u].p == NONE
		print("root\n")
	elsif $t[u].l == NONE && $t[u].r == NONE
		print("leaf\n")
	else
		print("internal node\n")
	end
end

$saiki = 0

def setHeight(u)
	#puts $saiki
	#$saiki += 1

	h1 = 0
	h2 = 0
	if $t[u].l != NONE
		h1 = setHeight($t[u].l) + 1 	
	end
	if $t[u].r != NONE
		h2 = setHeight($t[u].r) + 1 
	end
	$h[u] = h1 > h2 ? h1 : h2
	return $h[u]
end

def getSibling(u)
	return NONE if $t[u].p == NONE
	return $t[$t[u].p].l if $t[$t[u].p].l != u && $t[$t[u].p].l != NONE
	return $t[$t[u].p].r if $t[$t[u].p].r != u && $t[$t[u].p].r != NONE
	return NONE
end

def getDepth(u)
	d = 0
	while $t[u].p != NONE
		u = $t[u].p
		d += 1
	end
	return d
end

n = gets.to_i
for i in 0...n do
	$t[i] = Node.new(NONE, NONE, NONE)
end
for i in 0...n do
	v, l, r = gets.split.map &:to_i
	$t[v].l = l
	$t[v].r = r
	$t[l].p = v if l != NONE
	$t[r].p = v if r != NONE
end
for i in 0...n do
	root = i if $t[i].p == NONE
end
setHeight(root)
for i in 0...n do
	my_print(i)
end