class Node
  attr_accessor :id, :parent, :children

  def initialize(id, children)
    @id = id
    @parent = nil
    @children = children
  end

  def depth
    d = 0
    target = self
    while !target.parent.nil? do
      d += 1
      target = target.parent
    end
    return d 
  end

  def type
    if depth == 0
      'root'
    elsif children.empty?
      'leaf'
    else
      'internal node'
    end
  end

  def parent_id
    if parent.nil?
      -1
    else
      parent.id
    end
  end
end

n = gets.to_i
nodes = Array.new(n)
n.times do
  id, k, *cs = gets.split.map(&:to_i)
  node = Node.new(id, cs)
  nodes[id] = node
end

nodes.each do |parent|
  parent.children.each do |child|
    nodes[child].parent = parent
  end
end

# puts nodes.inspect

nodes.each do |node|
  puts "node #{node.id}: parent = #{node.parent_id}, depth = #{node.depth}, #{node.type}, #{node.children.to_s}"
end
