s=list(eval(input()))

s.reverse()

l=[1,10,9,12,3,4]

p=10**9+7

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

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)):

  if s[i]!='?':

    for j in range(13):

      dp[i][j]+=dp[i-1][(j-(int(s[i])*l[i%6]))%13]

      dp[i][j]%=p

  else:

    for j in range(13):

      for k in range(10):

        dp[i][j]+=dp[i-1][(j-k*l[i%6])%13]

        dp[i][j]%=p

print((dp[len(s)-1][5]))
s=list(eval(input()))

n=len(s)

s.reverse()

mod=10**9+7

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

dp[0][0]=1

x=1

for i in range(n):

  for j in range(13):

    if s[i]=='?':

      for k in range(10):

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

    else:

      dp[i+1][j]+=dp[i][(j-(int(s[i])*x)%13+13)%13]

    dp[i+1][j]%=mod

  x*=10

  x%=13

print((dp[n][5]))
s = list(eval(input()))
s.reverse()
l = [1, 10, 9, 12, 3, 4]
p = 10**9 + 7
dp = [[0 for i in range(13)] for j in range(len(s))]
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)):
    if s[i] != "?":
        for j in range(13):
            dp[i][j] += dp[i - 1][(j - (int(s[i]) * l[i % 6])) % 13]
            dp[i][j] %= p
    else:
        for j in range(13):
            for k in range(10):
                dp[i][j] += dp[i - 1][(j - k * l[i % 6]) % 13]
                dp[i][j] %= p
print((dp[len(s) - 1][5]))

s = list(eval(input()))
n = len(s)
s.reverse()
mod = 10**9 + 7
dp = [[0] * 13 for i in range(n + 1)]
dp[0][0] = 1
x = 1
for i in range(n):
    for j in range(13):
        if s[i] == "?":
            for k in range(10):
                dp[i + 1][j] += dp[i][(j - (k * x) % 13 + 13) % 13]
        else:
            dp[i + 1][j] += dp[i][(j - (int(s[i]) * x) % 13 + 13) % 13]
        dp[i + 1][j] %= mod
    x *= 10
    x %= 13
print((dp[n][5]))

+n = len(s) -l = [1, 10, 9, 12, 3, 4] -p = 10**9 + 7 -dp = [[0 for i in range(13)] for j in range(len(s))] -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)): -    if s[i] != "?": -        for j in range(13): -            dp[i][j] += dp[i - 1][(j - (int(s[i]) * l[i % 6])) % 13] -            dp[i][j] %= p -    else: -        for j in range(13): +mod = 10**9 + 7 +dp = [[0] * 13 for i in range(n + 1)] +dp[0][0] = 1 +x = 1 +for i in range(n): +    for j in range(13): +        if s[i] == "?": -                dp[i][j] += dp[i - 1][(j - k * l[i % 6]) % 13] -                dp[i][j] %= p -print((dp[len(s) - 1][5])) +                dp[i + 1][j] += dp[i][(j - (k * x) % 13 + 13) % 13] +        else: +            dp[i + 1][j] += dp[i][(j - (int(s[i]) * x) % 13 + 13) % 13] +        dp[i + 1][j] %= mod +    x *= 10 +    x %= 13 +print((dp[n][5]))