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