n = gets.to_i
x = []

n.times{
    x.push([0, -1, 0, "root", []])
}

n.times{
    id, num, *c = gets.split.map(&:to_i)
    if num > 0 then
        c.each{|l|
            x[l][1] = id
        }
        x[id][4] = c
        x[id][3] = "internal node"
    else
        x[id][3] = "leaf"
    end
    x[id][0] = id
}

def checkdepth(x, k, d)
     if k[1] == -1 then
        return d
     else
        checkdepth(x, x[k[1]], d+1)
     end
end

x.each{|k|
    k[2] = checkdepth(x, k, 0)
}

x.each{|k|
    if k[1] == -1 then
        k[3] = "root"
    end
    printf("node %d: parent = %d, depth = %d, %s, %s\n", k[0], k[1], k[2], k[3], k[4])
}

