class Node

  attr_accessor:id, :parent, :children

  def initialize(id, parent, children)
    @id = id
    @parent = parent
    @children = children
  end

  def parent_id
    if @parent.nil?
      -1
    else
      @parent.id
    end
  end

  def depth
    if @parent.nil?
      0
    else
      @parent.depth + 1
    end
  end

  def type
    if @parent.nil?
      "root"
    elsif @children.empty?
      "leaf"
    else
      "internal node"
    end
  end

  def to_s
    "node #{@id}: parent = #{parent_id}, depth = #{depth}, #{type}, [#{@children.join(', ')}]"
  end

end


n = STDIN.gets.to_i

tree = []
for i in 0..(n - 1)
  as = STDIN.gets.split(' ')
  id = as[0].to_i
  m = as[1].to_i
  parent_node = tree.find { |node|
    (node != nil) && (node.children.include? id)
  }

  children = as.drop(2).map { |x| x.to_i }

  node = Node.new(id, parent_node, children)

  children.each { |child_id|
    child_node = tree[child_id]
    if !child_node.nil?
      child_node.parent = node
    end
  }

  tree[id] = node
end

tree.each {|node|
  puts node
}