class RootedTree
  attr_accessor :nodes

  class Node
    attr_accessor :id, :children, :parent

    def initialize(id, parent = nil)
      @id = id
      @children = []
      @parent = parent
    end

    def type
      if @parent.id == -1
        "root"
      elsif @children.size == 0
        "leaf"
      else
        "internal node"
      end
    end

    def depth
      dep = 0
      parent = @parent
      while parent.id != -1
        dep += 1
        parent = parent.parent
      end
      return dep
    end

  end

  def initialize
    @nodes = []
    @root_parent = Node.new(-1)
  end

  # children ::= [1, 2, 14]
  def add_node(id, children)
    @nodes[id] = Node.new(id, @root_parent) unless @nodes[id]
    children.each do |i|
      if @nodes[i]
        @nodes[i].parent = @nodes[id]
      else
        @nodes[i] = Node.new(i, @nodes[id])
      end
      @nodes[id].children << @nodes[i]
    end
  end

  def print
    @nodes.each do |n|
      puts "node #{n.id}: parent = #{n.parent.id}, depth = #{n.depth}, #{n.type}, [#{n.children.map{ |c| c.id }*', '}]"
    end
  end

end

rt = RootedTree.new
n = gets.to_i
n.times do |k|
  id, k, *children = gets.split.map { |i| i.to_i }
  rt.add_node(id, children)
end
rt.print