def self_powers(d, stop, vol=0):
    """
    Returns the last d digits of 1^1 + 2^2 + ... + stop ^ stop
    """
    total = 0
    mod = 10 ** d
    for a in range(1, stop + 1):
        total += a ** a
        total %= mod
    if vol >= 1:
        print(f"The last {d} digits are {total}")
    return total