from collections import defaultdict

s = input()[::-1]

mod = 13

p = 10 ** 9 + 7

dic = defaultdict(int)

dic[0] = 1



for i in range(len(s)):

    tmp = defaultdict(int)

    if s[i] == "?":

        for j in range(10):

            d = j * pow(10, i, mod)

            for k, v in list(dic.items()):

                tmp[(k + d) % mod] += v

                tmp[(k + d) % mod] %= p

    else:

        d = int(s[i]) * pow(10, i, mod)

        for k, v in list(dic.items()):

            tmp[(k + d) % mod] = v

    dic = tmp

print((dic[5] % p))

s = input()[::-1]

mod = 13

p = 10 ** 9 + 7

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

dp[0][0] = 1



for i in range(len(s)):

    if s[i] == "?":

        for j in range(10):

            d = j * pow(10, i, mod)

            for k in range(13):

                dp[i + 1][(k + d) % mod] += dp[i][k]

                dp[i + 1][(k + d) % mod] %= p

    else:

        d = int(s[i]) * pow(10, i, mod)

        for k in range(13):

            dp[i + 1][(k + d) % mod] += dp[i][k]

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

from collections import defaultdict

s = input()[::-1]
mod = 13
p = 10**9 + 7
dic = defaultdict(int)
dic[0] = 1
for i in range(len(s)):
    tmp = defaultdict(int)
    if s[i] == "?":
        for j in range(10):
            d = j * pow(10, i, mod)
            for k, v in list(dic.items()):
                tmp[(k + d) % mod] += v
                tmp[(k + d) % mod] %= p
    else:
        d = int(s[i]) * pow(10, i, mod)
        for k, v in list(dic.items()):
            tmp[(k + d) % mod] = v
    dic = tmp
print((dic[5] % p))

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

-from collections import defaultdict - -dic = defaultdict(int) -dic[0] = 1 +dp = [[0] * 13 for _ in range(len(s) + 1)] +dp[0][0] = 1 -    tmp = defaultdict(int) -            for k, v in list(dic.items()): -                tmp[(k + d) % mod] += v -                tmp[(k + d) % mod] %= p +            for k in range(13): +                dp[i + 1][(k + d) % mod] += dp[i][k] +                dp[i + 1][(k + d) % mod] %= p -        for k, v in list(dic.items()): -            tmp[(k + d) % mod] = v -    dic = tmp -print((dic[5] % p)) +        for k in range(13): +            dp[i + 1][(k + d) % mod] += dp[i][k] +print((dp[-1][5]))