S=eval(input())

d=[0]*13

d[0]=1

for i in range(len(S)):

  n=[0]*13

  for j in range(13):

    for k in range(10):

      n[(10*j+k)%13]+=(1 if S[i]=='?' or int(S[i])==k else 0)*d[j]

  for j in range(13): d[j]=n[j]%(10**9+7)

print((d[5]))
S=eval(input())

d=[0]*13

d[0]=1

for i in range(len(S)):

  n=[0]*13

  for j in range(13):

    for k in range(10):

      if S[i]=='?' or int(S[i])==k: n[(10*j+k)%13]+=d[j]

  for j in range(13): d[j]=n[j]%(10**9+7)

print((d[5]))
S = eval(input())
d = [0] * 13
d[0] = 1
for i in range(len(S)):
    n = [0] * 13
    for j in range(13):
        for k in range(10):
            n[(10 * j + k) % 13] += (1 if S[i] == "?" or int(S[i]) == k else 0) * d[j]
    for j in range(13):
        d[j] = n[j] % (10**9 + 7)
print((d[5]))

S = eval(input())
d = [0] * 13
d[0] = 1
for i in range(len(S)):
    n = [0] * 13
    for j in range(13):
        for k in range(10):
            if S[i] == "?" or int(S[i]) == k:
                n[(10 * j + k) % 13] += d[j]
    for j in range(13):
        d[j] = n[j] % (10**9 + 7)
print((d[5]))

-            n[(10 * j + k) % 13] += (1 if S[i] == "?" or int(S[i]) == k else 0) * d[j] +            if S[i] == "?" or int(S[i]) == k: +                n[(10 * j + k) % 13] += d[j]