MOD = 10 ** 9 + 7



S = eval(input())

N = len(S)



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

dp[0][0] = 1



mul = 1



for i, x in enumerate(S[::-1]):

  if x == "?":

    for k in range(10):

      for j in range(13):

        jj = (mul * k + j) % 13

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

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

  else:

    k = int(x)

    for j in range(13):

      jj = (mul * k + j) % 13

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

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



  mul = (mul * 10) % 13



print((dp[N][5]))

S = eval(input())

n = len(S)



MOD = 10 ** 9 + 7



# dp[i][j] i桁までで、あまりjの個数

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

dp[0][0] = 1



for i, s in enumerate(S):

  if s == "?":

    c = -1

  else:

    c = int(s)

  for j in range(10):

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

      continue

    for k in range(13):

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

  for k in range(13):

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

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

S = eval(input())
n = len(S)
MOD = 10**9 + 7
# dp[i][j] i桁までで、あまりjの個数
dp = [[0] * 13 for _ in range(n + 1)]
dp[0][0] = 1
for i, s in enumerate(S):
    if s == "?":
        c = -1
    else:
        c = int(s)
    for j in range(10):
        if c != -1 and c != j:
            continue
        for k in range(13):
            dp[i + 1][(k * 10 + j) % 13] += dp[i][k]
    for k in range(13):
        dp[i + 1][k] %= MOD
print((dp[n][5]))

+S = eval(input()) +n = len(S) -S = eval(input()) -N = len(S) -dp = [[0] * 13 for _ in range(N + 1)] +# dp[i][j] i桁までで、あまりjの個数 +dp = [[0] * 13 for _ in range(n + 1)] -mul = 1 -for i, x in enumerate(S[::-1]): -    if x == "?": -        for k in range(10): -            for j in range(13): -                jj = (mul * k + j) % 13 -                dp[i + 1][jj] += dp[i][j] -                dp[i + 1][jj] %= MOD +for i, s in enumerate(S): +    if s == "?": +        c = -1 -        k = int(x) -        for j in range(13): -            jj = (mul * k + j) % 13 -            dp[i + 1][jj] += dp[i][j] -            dp[i + 1][jj] %= MOD -    mul = (mul * 10) % 13 -print((dp[N][5])) +        c = int(s) +    for j in range(10): +        if c != -1 and c != j: +            continue +        for k in range(13): +            dp[i + 1][(k * 10 + j) % 13] += dp[i][k] +    for k in range(13): +        dp[i + 1][k] %= MOD +print((dp[n][5]))