in_all = list(map(int, input().split()))



total = 0

for n in range(1, in_all[0]+1):

    tmp = str(n)

    all = 0

    for t in tmp:

        all += int(t)

    if all>=in_all[1] and all<=in_all[2]:

        total += int(tmp)



print(total)
in_all = list(map(int, input().split()))



total = 0

for n in range(1, in_all[0]+1):

    all = 0

    tmp = n

    while tmp!=0:

        all += tmp%10

        tmp = tmp//10

    if all>=in_all[1] and all<=in_all[2]:

        total += n



print(total)
in_all = list(map(int, input().split()))
total = 0
for n in range(1, in_all[0] + 1):
    tmp = str(n)
    all = 0
    for t in tmp:
        all += int(t)
    if all >= in_all[1] and all <= in_all[2]:
        total += int(tmp)
print(total)

in_all = list(map(int, input().split()))
total = 0
for n in range(1, in_all[0] + 1):
    all = 0
    tmp = n
    while tmp != 0:
        all += tmp % 10
        tmp = tmp // 10
    if all >= in_all[1] and all <= in_all[2]:
        total += n
print(total)

-    tmp = str(n) -    for t in tmp: -        all += int(t) +    tmp = n +    while tmp != 0: +        all += tmp % 10 +        tmp = tmp // 10 -        total += int(tmp) +        total += n