class Node
  attr_accessor :parent, :left, :right, :chlds

  def initialize(p, l, r, *chs)
    @parent = p
    @left   = l
    @right  = r
    @chlds  = chs
  end
end

def getDepth(k, d, node)
  if node[k].parent == -1
      d
  else
     getDepth(node[k].parent, d+1, node)
  end
end

def getKubun(k, nodes)
  if nodes[k].parent == -1
    "root"
  elsif nodes[k].left != nil
    "internal node"
  else
    "leaf"
  end
end

nodes = {}
n = gets.chomp.to_i

n.times {
  key, z, *chs = gets.chomp.split.map(&:to_i)

  if nodes[key] == nil
    nodes[key] = Node.new(-1, chs[0], nil, chs)
  else
      nodes[key].left = chs[0]
      nodes[key].chlds = chs
  end

  #-- 子要素について、parentとrightをセット
  chs.each_with_index { |ch, i|
    #-- parentのセット
    if nodes[ch] == nil
      nodes[ch] = Node.new(key, nil, nil, nil)
    else
      nodes[ch].parent = key
    end

    #-- rightのセット
    if i != chs.length - 1
      nodes[ch].right = chs[i + 1]
    end
  }
}

#-- 表示
[*0...n].each { |i|
  print "node #{i}: parent = #{nodes[i].parent}, depth = #{getDepth(i, 0, nodes)}, #{getKubun(i, nodes)}, "
  p nodes[i].chlds.flatten
}
