S = eval(input())

con = 10**9 + 7



T = [s if s != "?" else "0" for s in S]

T = int(''.join(T))

SS = T % 13



def get_mod(S):

    c = {}

    iii = 1

    for i in range(len(S)):

        if S[len(S) - i - 1] != "?":

            iii *= 10

            iii %= 13

            continue

        c[i] = {(j * iii) % 13: 1 for j in range(0, 10)}

        iii *= 10

        iii %= 13

    return c

c = get_mod(S)



def get_tdp(pdp):

    tdp = {i: 0 for i in range(13)}

    for r in list(v.keys()):

        for _r, _v in list(pdp.items()):

            i = (_r + r) % 13

            tdp[i] += _v

    for i in range(13):

        tdp[i] %= con

    return tdp



pdp = {i: 0 for i in range(13)}

pdp[SS] += 1

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

    pdp = get_tdp(pdp)



ans = pdp[5]

print(ans)
N = input()[::-1]

iv = 1

MOD = 10**9+7

pdp = [0 for i in range(13)]

pdp[0]=1

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

for i in range(len(N)):

  x = N[i]

  if x=='?':

    for j in range(13):

      for h in range(10):

        dp[(h*iv+j)%13] += pdp[j]

    for j in range(13):

      pdp[j] = (dp[j]%MOD)

      dp[j] = 0

  else:

    x = int(x)

    for j in range(13):

      dp[(j+x*iv)%13]+=pdp[j]

    for j in range(13):

      pdp[j] = (dp[j]%MOD)

      dp[j]=0

  iv *= 10

  iv %= 13

print((pdp[5]))
S = eval(input())
con = 10**9 + 7
T = [s if s != "?" else "0" for s in S]
T = int("".join(T))
SS = T % 13


def get_mod(S):
    c = {}
    iii = 1
    for i in range(len(S)):
        if S[len(S) - i - 1] != "?":
            iii *= 10
            iii %= 13
            continue
        c[i] = {(j * iii) % 13: 1 for j in range(0, 10)}
        iii *= 10
        iii %= 13
    return c


c = get_mod(S)


def get_tdp(pdp):
    tdp = {i: 0 for i in range(13)}
    for r in list(v.keys()):
        for _r, _v in list(pdp.items()):
            i = (_r + r) % 13
            tdp[i] += _v
    for i in range(13):
        tdp[i] %= con
    return tdp


pdp = {i: 0 for i in range(13)}
pdp[SS] += 1
for k, v in list(c.items()):
    pdp = get_tdp(pdp)
ans = pdp[5]
print(ans)

N = input()[::-1]
iv = 1
MOD = 10**9 + 7
pdp = [0 for i in range(13)]
pdp[0] = 1
dp = [0 for i in range(13)]
for i in range(len(N)):
    x = N[i]
    if x == "?":
        for j in range(13):
            for h in range(10):
                dp[(h * iv + j) % 13] += pdp[j]
        for j in range(13):
            pdp[j] = dp[j] % MOD
            dp[j] = 0
    else:
        x = int(x)
        for j in range(13):
            dp[(j + x * iv) % 13] += pdp[j]
        for j in range(13):
            pdp[j] = dp[j] % MOD
            dp[j] = 0
    iv *= 10
    iv %= 13
print((pdp[5]))

-S = eval(input()) -con = 10**9 + 7 -T = [s if s != "?" else "0" for s in S] -T = int("".join(T)) -SS = T % 13 - - -def get_mod(S): -    c = {} -    iii = 1 -    for i in range(len(S)): -        if S[len(S) - i - 1] != "?": -            iii *= 10 -            iii %= 13 -            continue -        c[i] = {(j * iii) % 13: 1 for j in range(0, 10)} -        iii *= 10 -        iii %= 13 -    return c - - -c = get_mod(S) - - -def get_tdp(pdp): -    tdp = {i: 0 for i in range(13)} -    for r in list(v.keys()): -        for _r, _v in list(pdp.items()): -            i = (_r + r) % 13 -            tdp[i] += _v -    for i in range(13): -        tdp[i] %= con -    return tdp - - -pdp = {i: 0 for i in range(13)} -pdp[SS] += 1 -for k, v in list(c.items()): -    pdp = get_tdp(pdp) -ans = pdp[5] -print(ans) +N = input()[::-1] +iv = 1 +MOD = 10**9 + 7 +pdp = [0 for i in range(13)] +pdp[0] = 1 +dp = [0 for i in range(13)] +for i in range(len(N)): +    x = N[i] +    if x == "?": +        for j in range(13): +            for h in range(10): +                dp[(h * iv + j) % 13] += pdp[j] +        for j in range(13): +            pdp[j] = dp[j] % MOD +            dp[j] = 0 +    else: +        x = int(x) +        for j in range(13): +            dp[(j + x * iv) % 13] += pdp[j] +        for j in range(13): +            pdp[j] = dp[j] % MOD +            dp[j] = 0 +    iv *= 10 +    iv %= 13 +print((pdp[5]))