class Node
  attr_reader :id
  attr_writer :parent

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

  def add_child(child)
    @children << child
    child.parent = self
  end

  def child_ids
    @children.map{|n| n.id }.join(', ')
  end

  def type
    return 'root' if @parent.nil?
    return 'leaf' if @children.empty?
    'internal node'
  end

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

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

n = gets.to_i
nodes = n.times.map{|id| Node.new(id) }

n.times do
  id, k, *child = gets.split.map(&:to_i)
  child.each do |child_id|
    nodes[id].add_child(nodes[child_id])
  end
end

nodes.each do |n|
  puts "node #{n.id}: parent = #{n.parent_id}, depth = #{n.depth}, #{n.type}, [#{n.child_ids}]"
end