a=[]
class Tree
    attr_accessor :id, :parent, :depth, :children, :type
    def initialize(id, children)
        @id = id
        @parent = -1
        @depth = 0
        @children = children
        @type = (children == [] ? 'leaf' : 'internal node')
    end

    def print
        puts "node #{@id}: parent = #{@parent}, depth = #{@depth}, #{@type}, #{children}"
    end
end

N = gets.to_i

N.times {
    id, d, *children = gets.split.map(&:to_i)
    a << Tree.new(id, children)
}
a.sort_by! {|e| e.id}
a.each {|ele|
    ele.children.each {|e|
        a[e].parent = ele.id
    }
}
a.each {|e|
    if e.parent == -1
        e.type = 'root'
    else
        e.depth = a[e.parent].depth + 1
    end
}
a.each {|e| e.print}