class Vertex
  include Comparable
  attr_reader :parent, :id, :children
  def initialize(n, degree, *children)
    @id = n
    @parent = -1
    if degree != 0
      @children = children
    else
      @children = []
    end
    if degree != 0
      @type ="root"
    else
      @type = "leaf"
    end
  end
  
  def to_s
    return "node #{@id}: parent = #{@parent == -1 ? @parent: @parent.id}, depth = #{depth}, #{@type}, [#{@children.join(", ")}]"
  end
  
  def depth
    if @parent != -1
      return @parent.depth + 1
    else
      return 0
    end
  end
  
  def set_parent(parent)
    @parent = parent
    if @type == "root"
      @type = "internal node"
    end
  end
  
  def <=>(other)
    @id <=> other.id
  end
end
def main
  arr = []
  gets.to_i.times do
    arr << Vertex.new(*gets.split(" ").map(&:to_i))
  end
  arr.sort!
  arr.each{|item|
    item.children.each{|child|
      arr[child].set_parent(item)
      }
    }
  puts arr
end
main