class Node
  def initialize(id)
    @id = id
    @parent = -1
    @depth = 0
    @type = nil
    @children = []
  end

  attr_accessor :id, :parent, :depth, :type, :children
end

def assign(node, depth)
  if (node.parent == -1) then
    node.type = "root"
  else
    node.type = (node.children.size > 0) ? "internal node" : "leaf"
  end

  node.depth = depth

  node.children.each do |index|
    assign($node_map[index], depth+1)
  end
end

n = gets.chomp.to_i
$node_map = {}
n.times do |index|
  $node_map[index] = Node.new(index)
end

n.times do
  array = gets.chomp.split.map(&:to_i)
  if (array[1] > 0) then
    $node_map[array[0]].children = array[2..-1]
  end
  array[2..-1].each do |item|
    $node_map[item].parent = array[0]
  end
end

root_map = $node_map.select{|key, val| val.parent == -1}
assign(root_map.values[0], 0)

$node_map.each do |key, node|
  puts "node #{node.id}: parent = #{node.parent}, depth = #{node.depth}, #{node.type}, #{node.children}"
end