class RootedTree
	attr_accessor :lch, :rsbl, :parent
	
	def format(id)
		puts "node #{id}: parent = #{self.parent}, depth = #{self.get_depth}, #{self.get_type}, #{self.get_children}"
	end
	
	def initialize(parent = -1, lch = nil, rsbl = nil)
		@parent = parent
		@lch = lch
		@rsbl = rsbl
	end
	
	def get_depth
		depth = 0
		i = self.parent
		while true
			return depth if i == -1
			i = $nodes[i].parent
			depth += 1
		end
	end
	
	def get_type
		if self.parent == -1
			return "root"
		else
			if self.lch == nil
				return "leaf"
			else
				return "internal node"
			end
		end
	end
	
	def get_children
		child = self.lch
		r = []
		while child
			r.push(child)
			child = $nodes[child].rsbl
		end
		return r
	end
end

n=gets.chomp.to_i
$nodes = []
n.times{|i|$nodes[i] = RootedTree.new}

n.times do
	node_id, dim, *ch_list = gets.chomp.split(" ").map{|j|j.to_i}
	next if dim == 0
	$nodes[node_id].lch = ch_list[0]
	dim.times do |d|
		$nodes[ch_list[d]].parent = node_id
		$nodes[ch_list[d]].rsbl = ch_list[d+1] if ch_list[d+1]
	end
end

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