$a=Array.new()
class Tree
  attr_accessor :id,:parent,:depth,:children,:type
  def initialize(id,children)
    @id=id
    @parent=-1
    @children=children
    @type=(children==[] ? 'leaf' : 'internal node')
  end
  def print
    puts "node #{id}: parent = #{parent}, depth = #{depth}, #{type}, #{children}"
  end
  def setDepth
    children.each do |c|
      $a[c].depth = depth + 1
      $a[c].setDepth
    end
  end
end
n=gets.to_i
n.times do
  id,d,*children=gets.split.map(&:to_i)
  $a << Tree.new(id,children)
end
$a.sort_by! {|e| e.id}
$a.each {|ele|
  ele.children.each {|e|
    $a[e].parent=ele.id
  }
}
$a.each do |e|
  if e.parent==-1
    e.type='root'
    e.depth=0
    e.setDepth
  end
end
$a.each {|e| e.print}