class Node
  attr_accessor :par, :left_cld, :right_sib, :depth, :childs, :type, :id
  def initialize()
    @par = -1
    @left_cld = nil
    @right_sib = nil
    @depth = nil
    @childs = []
    @type = "internal node"
    @id = nil
  end
end

#入力
n = gets.to_i
inputs = Array.new(n){gets.split.map(&:to_i)}.sort

#ノード生成ここから
$nodes = Array.new(n){Node.new}
inputs.each_with_index do |input, i|
  #もし子がないならnext
  if input[1] == 0
    next
  end

  #parを設定
  input[2..-1].each do |num|
    $nodes[num].par = i
  end

  #left_cldを設定
  $nodes[i].left_cld = input[2]

  #right_sibを設定
  tmp = input[2..-1] + [nil]
  tmp.each_with_index do |num, j|
    if num
      $nodes[num].right_sib = tmp[j+1]
    end
  end
end

def set_depth(id, depth)
  $nodes[id].depth = depth

  if $nodes[id].right_sib
    set_depth($nodes[id].right_sib, depth)
  end

  if $nodes[id].left_cld
    set_depth($nodes[id].left_cld, depth+1)
  end
end

def set_childs
  $nodes.each do |node|
    c = node.left_cld
    while c
      node.childs << c
      c = $nodes[c].right_sib
    end
  end
end

def set_type
  $nodes.each_with_index do |node, k|
    if node.par == -1
      node.type = "root"
      set_depth(k,0)
    elsif !node.left_cld
      node.type = "leaf"
    end
  end
end

set_childs()
set_type()
#ノード生成ここまで

#p inputs[0]
$nodes.each_with_index do |n, i|
  #p i
  #p n
  puts 'node %d: parent = %d, depth = %d, %s, %s' % [i, n.par, n.depth, n.type, n.childs.to_s]
end
