s = eval(input())

MOD = 10**9 + 7



dp = [[0 for i in range(13)] for j in range(2)]

if s[0] == '?':

    for i in range(10):

        dp[0][i] = 1

else:

    dp[0][int(s[0])] = 1



for i in range(1, len(s)):

    for j in range(13):

        dp[i%2][j] = 0



    if s[i] == '?':

        for j in range(13):

            for k in range(10):

                dp[i%2][(10*j+k)%13] = (dp[i%2][(10*j+k)%13] + dp[(i-1)%2][j]) % MOD

    else:

        k = int(s[i])

        for j in range(13):

            dp[i%2][(10*j+k)%13] = (dp[i%2][(10*j+k)%13] + dp[(i-1)%2][j]) % MOD



    # print(dp[(i-1)%2])

    # print(dp[i%2])

    # print()





print((dp[(len(s)-1)%2][5]))

MOD = 10**9 + 7

s = eval(input())

n = len(s)



# dp[i][r] = (最初のi桁を見て、余りがrとなるような個数)

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

dp[0][0] = 1



for i in range(n):

    if s[i] == '?':

        for r in range(13):

            for d in range(10):

                r1 = (r * 10 + d) % 13

                dp[i + 1][r1] += dp[i][r]

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

    else:

        for r in range(13):

            r1 = (r * 10 + int(s[i])) % 13

            dp[i + 1][r1] += dp[i][r]

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



ans = dp[n][5]

# print(*dp, sep='\n')

print(ans)

s = eval(input())
MOD = 10**9 + 7
dp = [[0 for i in range(13)] for j in range(2)]
if s[0] == "?":
    for i in range(10):
        dp[0][i] = 1
else:
    dp[0][int(s[0])] = 1
for i in range(1, len(s)):
    for j in range(13):
        dp[i % 2][j] = 0
    if s[i] == "?":
        for j in range(13):
            for k in range(10):
                dp[i % 2][(10 * j + k) % 13] = (
                    dp[i % 2][(10 * j + k) % 13] + dp[(i - 1) % 2][j]
                ) % MOD
    else:
        k = int(s[i])
        for j in range(13):
            dp[i % 2][(10 * j + k) % 13] = (
                dp[i % 2][(10 * j + k) % 13] + dp[(i - 1) % 2][j]
            ) % MOD
    # print(dp[(i-1)%2])
    # print(dp[i%2])
    # print()
print((dp[(len(s) - 1) % 2][5]))

MOD = 10**9 + 7
s = eval(input())
n = len(s)
# dp[i][r] = (最初のi桁を見て、余りがrとなるような個数)
dp = [[0] * 13 for _ in range(n + 1)]
dp[0][0] = 1
for i in range(n):
    if s[i] == "?":
        for r in range(13):
            for d in range(10):
                r1 = (r * 10 + d) % 13
                dp[i + 1][r1] += dp[i][r]
                dp[i + 1][r1] %= MOD
    else:
        for r in range(13):
            r1 = (r * 10 + int(s[i])) % 13
            dp[i + 1][r1] += dp[i][r]
            dp[i + 1][r1] %= MOD
ans = dp[n][5]
# print(*dp, sep='\n')
print(ans)

+MOD = 10**9 + 7 -MOD = 10**9 + 7 -dp = [[0 for i in range(13)] for j in range(2)] -if s[0] == "?": -    for i in range(10): -        dp[0][i] = 1 -else: -    dp[0][int(s[0])] = 1 -for i in range(1, len(s)): -    for j in range(13): -        dp[i % 2][j] = 0 +n = len(s) +# dp[i][r] = (最初のi桁を見て、余りがrとなるような個数) +dp = [[0] * 13 for _ in range(n + 1)] +dp[0][0] = 1 +for i in range(n): -        for j in range(13): -            for k in range(10): -                dp[i % 2][(10 * j + k) % 13] = ( -                    dp[i % 2][(10 * j + k) % 13] + dp[(i - 1) % 2][j] -                ) % MOD +        for r in range(13): +            for d in range(10): +                r1 = (r * 10 + d) % 13 +                dp[i + 1][r1] += dp[i][r] +                dp[i + 1][r1] %= MOD -        k = int(s[i]) -        for j in range(13): -            dp[i % 2][(10 * j + k) % 13] = ( -                dp[i % 2][(10 * j + k) % 13] + dp[(i - 1) % 2][j] -            ) % MOD -    # print(dp[(i-1)%2]) -    # print(dp[i%2]) -    # print() -print((dp[(len(s) - 1) % 2][5])) +        for r in range(13): +            r1 = (r * 10 + int(s[i])) % 13 +            dp[i + 1][r1] += dp[i][r] +            dp[i + 1][r1] %= MOD +ans = dp[n][5] +# print(*dp, sep='\n') +print(ans)