d=[1]+[0]*12

for c in eval(input()):

 p=[0]*13

 for j in range(13):

  for k in range(10):t=(j*10+k)%13;p[t]+=d[j]*(c>'9'or k==int(c));p[t]%=10**9+7

 d=p

print((d[5]))
d=[1]+[0]*12

for c in eval(input()):

	e=[0]*13

	for k in([c],list(range(10)))[c>'9']:

		for j in range(13):t=(j*10+int(k))%13;e[t]+=d[j];e[t]%=10**9+7

	d=e

print((d[5]))
d = [1] + [0] * 12
for c in eval(input()):
    p = [0] * 13
    for j in range(13):
        for k in range(10):
            t = (j * 10 + k) % 13
            p[t] += d[j] * (c > "9" or k == int(c))
            p[t] %= 10**9 + 7
    d = p
print((d[5]))

d = [1] + [0] * 12
for c in eval(input()):
    e = [0] * 13
    for k in ([c], list(range(10)))[c > "9"]:
        for j in range(13):
            t = (j * 10 + int(k)) % 13
            e[t] += d[j]
            e[t] %= 10**9 + 7
    d = e
print((d[5]))

-    p = [0] * 13 -    for j in range(13): -        for k in range(10): -            t = (j * 10 + k) % 13 -            p[t] += d[j] * (c > "9" or k == int(c)) -            p[t] %= 10**9 + 7 -    d = p +    e = [0] * 13 +    for k in ([c], list(range(10)))[c > "9"]: +        for j in range(13): +            t = (j * 10 + int(k)) % 13 +            e[t] += d[j] +            e[t] %= 10**9 + 7 +    d = e