S = eval(input())

MOD = 10**9 + 7



p = [ (10**k)%13 for k in range(6) ]

mod_tb = [ [i*p[k]%13 for i in range(10)] for k in range(6) ]

n = [0]*6

base = 0

for k in range(len(S)):

    s = S[-(k+1)]

    if s == '?':

        n[k%6] += 1

    else:

        base += p[k%6]*int(s)

        base %= 13



DP = [ [0] * 13 for _ in range(sum(n)+1) ]

DP[0][base] = 1

i = 1

for k in range(6):

    for _ in range(n[k]):

        for m in range(13):

            for d in range(10):

                DP[i][(m + mod_tb[k][d])%13] += DP[i-1][m]

        for m in range(13):

            DP[i][m] %= MOD

        i += 1

print((DP[-1][5]))
MOD = 10**9 + 7

S = eval(input())



cur = [0] * 13

cur[0] = 1

r = 1

for i in range(len(S)):

    s = S[-(i+1)]

    if s == '?':

        digits = list(range(10))

    else:

        digits = [int(s)]



    prev = cur

    cur = [0] * 13

    for m in range(13):

        for d in digits:

            cur[(m + r*d) % 13] += prev[m]

    for m in range(13):

        cur[m] %= MOD

    r = (10 * r) % 13



print((cur[5]))
S = eval(input())
MOD = 10**9 + 7
p = [(10**k) % 13 for k in range(6)]
mod_tb = [[i * p[k] % 13 for i in range(10)] for k in range(6)]
n = [0] * 6
base = 0
for k in range(len(S)):
    s = S[-(k + 1)]
    if s == "?":
        n[k % 6] += 1
    else:
        base += p[k % 6] * int(s)
        base %= 13
DP = [[0] * 13 for _ in range(sum(n) + 1)]
DP[0][base] = 1
i = 1
for k in range(6):
    for _ in range(n[k]):
        for m in range(13):
            for d in range(10):
                DP[i][(m + mod_tb[k][d]) % 13] += DP[i - 1][m]
        for m in range(13):
            DP[i][m] %= MOD
        i += 1
print((DP[-1][5]))

MOD = 10**9 + 7
S = eval(input())
cur = [0] * 13
cur[0] = 1
r = 1
for i in range(len(S)):
    s = S[-(i + 1)]
    if s == "?":
        digits = list(range(10))
    else:
        digits = [int(s)]
    prev = cur
    cur = [0] * 13
    for m in range(13):
        for d in digits:
            cur[(m + r * d) % 13] += prev[m]
    for m in range(13):
        cur[m] %= MOD
    r = (10 * r) % 13
print((cur[5]))

+MOD = 10**9 + 7 -MOD = 10**9 + 7 -p = [(10**k) % 13 for k in range(6)] -mod_tb = [[i * p[k] % 13 for i in range(10)] for k in range(6)] -n = [0] * 6 -base = 0 -for k in range(len(S)): -    s = S[-(k + 1)] +cur = [0] * 13 +cur[0] = 1 +r = 1 +for i in range(len(S)): +    s = S[-(i + 1)] -        n[k % 6] += 1 +        digits = list(range(10)) -        base += p[k % 6] * int(s) -        base %= 13 -DP = [[0] * 13 for _ in range(sum(n) + 1)] -DP[0][base] = 1 -i = 1 -for k in range(6): -    for _ in range(n[k]): -        for m in range(13): -            for d in range(10): -                DP[i][(m + mod_tb[k][d]) % 13] += DP[i - 1][m] -        for m in range(13): -            DP[i][m] %= MOD -        i += 1 -print((DP[-1][5])) +        digits = [int(s)] +    prev = cur +    cur = [0] * 13 +    for m in range(13): +        for d in digits: +            cur[(m + r * d) % 13] += prev[m] +    for m in range(13): +        cur[m] %= MOD +    r = (10 * r) % 13 +print((cur[5]))