n = gets.chomp.to_i

nodes = []
n.times {
    words = gets.chomp.split.map &:to_i
    id = words[0]
    node = {
        "id" => id,
        "dim" => words[1],
        "children" => words[2..-1],
        "parent" => -1,
    }
    nodes[id] = node
}

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

id_root = 0
nodes.each do |node|
    if node["parent"] == -1
        node["species"] = "root"
        id_root = node["id"]
    elsif
        if node["children"].size == 0 then node["species"] = "leaf"
        else node["species"] = "internal node" end
    end
end

def rec(nodes, id, depth)
    nodes[id]["depth"] = depth
    nodes[id]["children"].each do |child| rec nodes, child, depth + 1 end
end

rec nodes, id_root, 0

nodes.each do |node|
    puts "node #{node["id"]}: parent = #{node["parent"]}, " \
        << "depth = #{node["depth"]}, #{node["species"]}, " \
        << "[#{node["children"].join(", ")}]"
end
