MOD = 10**9 + 7



Ss = eval(input())



N = len(Ss)



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

dp[0][0] = 1

for d, Sd in enumerate(Ss):

#    print(d, Sd)

    for mod13 in range(13):

        if Sd != '?':

            x = int(Sd)

            mod13n = (10*mod13 + x) % 13

            dp[d+1][mod13n] += dp[d][mod13]

            dp[d+1][mod13n] %= MOD

        else:

            for x in range(10):

                mod13n = (10*mod13 + x) % 13

                dp[d+1][mod13n] += dp[d][mod13]

                dp[d+1][mod13n] %= MOD



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

MOD = 10**9 + 7



Ss = input().rstrip()



lenS = len(Ss)



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

dp[0][0] = 1

for i, S in enumerate(Ss):

    for j in range(13):

        dp[i][j] %= MOD

    if S != '?':

        S = int(S)

        for j in range(13):

            j2 = (j*10+S) % 13

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

    else:

        for S in range(10):

            for j in range(13):

                j2 = (j*10+S) % 13

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



ans = dp[lenS][5] % MOD

print(ans)

MOD = 10**9 + 7
Ss = eval(input())
N = len(Ss)
dp = [[0] * (13) for _ in range(N + 1)]
dp[0][0] = 1
for d, Sd in enumerate(Ss):
    #    print(d, Sd)
    for mod13 in range(13):
        if Sd != "?":
            x = int(Sd)
            mod13n = (10 * mod13 + x) % 13
            dp[d + 1][mod13n] += dp[d][mod13]
            dp[d + 1][mod13n] %= MOD
        else:
            for x in range(10):
                mod13n = (10 * mod13 + x) % 13
                dp[d + 1][mod13n] += dp[d][mod13]
                dp[d + 1][mod13n] %= MOD
print((dp[-1][5]))

MOD = 10**9 + 7
Ss = input().rstrip()
lenS = len(Ss)
dp = [[0] * (13) for _ in range(lenS + 1)]
dp[0][0] = 1
for i, S in enumerate(Ss):
    for j in range(13):
        dp[i][j] %= MOD
    if S != "?":
        S = int(S)
        for j in range(13):
            j2 = (j * 10 + S) % 13
            dp[i + 1][j2] += dp[i][j]
    else:
        for S in range(10):
            for j in range(13):
                j2 = (j * 10 + S) % 13
                dp[i + 1][j2] += dp[i][j]
ans = dp[lenS][5] % MOD
print(ans)

-Ss = eval(input()) -N = len(Ss) -dp = [[0] * (13) for _ in range(N + 1)] +Ss = input().rstrip() +lenS = len(Ss) +dp = [[0] * (13) for _ in range(lenS + 1)] -for d, Sd in enumerate(Ss): -    #    print(d, Sd) -    for mod13 in range(13): -        if Sd != "?": -            x = int(Sd) -            mod13n = (10 * mod13 + x) % 13 -            dp[d + 1][mod13n] += dp[d][mod13] -            dp[d + 1][mod13n] %= MOD -        else: -            for x in range(10): -                mod13n = (10 * mod13 + x) % 13 -                dp[d + 1][mod13n] += dp[d][mod13] -                dp[d + 1][mod13n] %= MOD -print((dp[-1][5])) +for i, S in enumerate(Ss): +    for j in range(13): +        dp[i][j] %= MOD +    if S != "?": +        S = int(S) +        for j in range(13): +            j2 = (j * 10 + S) % 13 +            dp[i + 1][j2] += dp[i][j] +    else: +        for S in range(10): +            for j in range(13): +                j2 = (j * 10 + S) % 13 +                dp[i + 1][j2] += dp[i][j] +ans = dp[lenS][5] % MOD +print(ans)