S = eval(input())



MOD = 10 ** 9 + 7

MAX_LEN = len(S)

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

dp[0][0] = 1



for i in range(MAX_LEN):

    c = int(S[i]) if S[i] != '?' else -1

    for j in range(10):

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

            continue

        

        for k in range(13):

            idx = (k * 10 + j) % 13

            dp[i + 1][idx] += dp[i][k]

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

        

print((dp[-1][5]))



S = eval(input())



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

dp[0][0] = 1

mod = 10 ** 9 + 7

for i in range(len(S)):

    for j in range(13):

        if S[i] == "?":

            for k in range(10):

                x = (j * 10 + k) % 13

                dp[i + 1][x] += dp[i][j]

                dp[i + 1][x] %= mod

        else:

            x = (j * 10 + int(S[i])) % 13

            dp[i + 1][x] += dp[i][j]

            dp[i + 1][x] %= mod

            

print((dp[-1][5]))

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

S = eval(input())
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1
mod = 10**9 + 7
for i in range(len(S)):
    for j in range(13):
        if S[i] == "?":
            for k in range(10):
                x = (j * 10 + k) % 13
                dp[i + 1][x] += dp[i][j]
                dp[i + 1][x] %= mod
        else:
            x = (j * 10 + int(S[i])) % 13
            dp[i + 1][x] += dp[i][j]
            dp[i + 1][x] %= mod
print((dp[-1][5]))

-MOD = 10**9 + 7 -MAX_LEN = len(S) -dp = [[0] * 13 for _ in range(MAX_LEN + 1)] +dp = [[0] * 13 for _ in range(len(S) + 1)] -for i in range(MAX_LEN): -    c = int(S[i]) if S[i] != "?" else -1 -    for j in range(10): -        if c != -1 and c != j: -            continue -        for k in range(13): -            idx = (k * 10 + j) % 13 -            dp[i + 1][idx] += dp[i][k] -            dp[i + 1][idx] %= MOD +mod = 10**9 + 7 +for i in range(len(S)): +    for j in range(13): +        if S[i] == "?": +            for k in range(10): +                x = (j * 10 + k) % 13 +                dp[i + 1][x] += dp[i][j] +                dp[i + 1][x] %= mod +        else: +            x = (j * 10 + int(S[i])) % 13 +            dp[i + 1][x] += dp[i][j] +            dp[i + 1][x] %= mod