MOD = 10**9 + 7

S = eval(input())



cur = [0] * 13

cur[0] = 1

r = 1

base = 0

for i in range(len(S)):

    s = S[-(i+1)]

    if s == '?':

        prev = cur

        cur = [sum(prev)] * 13

        for m in range(13):

            for d in range(10,13):

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

        for m in range(13):

            cur[m] %= MOD

    else:

        base = (base + r*int(s)) % 13



    r = (10 * r) % 13



print((cur[(5-base) % 13]))
s = eval(input())

n = len(s)

MOD = 10**9 + 7

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

dp[0][0] = 1

for i in range(n):

    if s[i] == '?':

        c = -1

    else:

        c = int(s[i])



    for j in range(10):

        if c != -1 and c != j:

            continue

        for ki in range(13):

            dp[i+1][(ki*10 + j) % 13] += dp[i][ki]

    for j in range(13):

        dp[i+1][j] %= MOD



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

s = eval(input())
n = len(s)
MOD = 10**9 + 7
dp = [[0] * 13 for _ in range(n + 1)]
dp[0][0] = 1
for i in range(n):
    if s[i] == "?":
        c = -1
    else:
        c = int(s[i])
    for j in range(10):
        if c != -1 and c != j:
            continue
        for ki in range(13):
            dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki]
    for j in range(13):
        dp[i + 1][j] %= MOD
print((dp[n][5]))

+s = eval(input()) +n = len(s) -S = eval(input()) -cur = [0] * 13 -cur[0] = 1 -r = 1 -base = 0 -for i in range(len(S)): -    s = S[-(i + 1)] -    if s == "?": -        prev = cur -        cur = [sum(prev)] * 13 -        for m in range(13): -            for d in range(10, 13): -                cur[(m + r * d) % 13] -= prev[m] -        for m in range(13): -            cur[m] %= MOD +dp = [[0] * 13 for _ in range(n + 1)] +dp[0][0] = 1 +for i in range(n): +    if s[i] == "?": +        c = -1 -        base = (base + r * int(s)) % 13 -    r = (10 * r) % 13 -print((cur[(5 - base) % 13])) +        c = int(s[i]) +    for j in range(10): +        if c != -1 and c != j: +            continue +        for ki in range(13): +            dp[i + 1][(ki * 10 + j) % 13] += dp[i][ki] +    for j in range(13): +        dp[i + 1][j] %= MOD +print((dp[n][5]))