output_description: Print the number of integers satisfying the condition, modulo 10^9+7.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      S
attempt: ip = list(str(input()))
  a = [0] * len(ip)
  for i in range(len(ip)):
      if ip[i] == "?":
          a[i] += 1
  tmp = []
  s = ""
  
  
  def nums0(s):
      if len(s) < sum(a):
          s += "0"
          nums0(s)
          nums1(s)
          nums2(s)
          nums3(s)
          nums4(s)
          nums5(s)
          nums6(s)
          nums7(s)
          nums8(s)
          nums9(s)
      else:
          tmp.append(s)
  
  
  def nums1(s):
      if len(s) < sum(a):
          s += "1"
          nums0(s)
          nums1(s)
          nums2(s)
          nums3(s)
          nums4(s)
          nums5(s)
          nums6(s)
          nums7(s)
          nums8(s)
          nums9(s)
      else:
          tmp.append(s)
  
  
  def nums2(s):
      if len(s) < sum(a):
          s += "2"
          nums0(s)
          nums1(s)
          nums2(s)
          nums3(s)
          nums4(s)
          nums5(s)
          nums6(s)
          nums7(s)
          nums8(s)
          nums9(s)
      else:
          tmp.append(s)
  
  
  def nums3(s):
      if len(s) < sum(a):
          s += "3"
          nums0(s)
          nums1(s)
          nums2(s)
          nums3(s)
          nums4(s)
          nums5(s)
          nums6(s)
          nums7(s)
          nums8(s)
          nums9(s)
      else:
          tmp.append(s)
  
  
  def nums4(s):
      if len(s) < sum(a):
          s += "4"
          nums0(s)
          nums1(s)
          nums2(s)
          nums3(s)
          nums4(s)
          nums5(s)
          nums6(s)
          nums7(s)
          nums8(s)
          nums9(s)
      else:
          tmp.append(s)
  
  
  def nums5(s):
      if len(s) < sum(a):
          s += "5"
          nums0(s)
          nums1(s)
          nums2(s)
          nums3(s)
          nums4(s)
          nums5(s)
          nums6(s)
          nums7(s)
          nums8(s)
          nums9(s)
      else:
          tmp.append(s)
  
  
  def nums6(s):
      if len(s) < sum(a):
          s += "6"
          nums0(s)
          nums1(s)
          nums2(s)
          nums3(s)
          nums4(s)
          nums5(s)
          nums6(s)
          nums7(s)
          nums8(s)
          nums9(s)
      else:
          tmp.append(s)
  
  
  def nums7(s):
      if len(s) < sum(a):
          s += "7"
          nums0(s)
          nums1(s)
          nums2(s)
          nums3(s)
          nums4(s)
          nums5(s)
          nums6(s)
          nums7(s)
          nums8(s)
          nums9(s)
      else:
          tmp.append(s)
  
  
  def nums8(s):
      if len(s) < sum(a):
          s += "8"
          nums0(s)
          nums1(s)
          nums2(s)
          nums3(s)
          nums4(s)
          nums5(s)
          nums6(s)
          nums7(s)
          nums8(s)
          nums9(s)
      else:
          tmp.append(s)
  
  
  def nums9(s):
      if len(s) < sum(a):
          s += "9"
          nums0(s)
          nums1(s)
          nums2(s)
          nums3(s)
          nums4(s)
          nums5(s)
          nums6(s)
          nums7(s)
          nums8(s)
          nums9(s)
      else:
          tmp.append(s)
  
  
  if a[0] == 0:
      nums1(s)
      nums2(s)
      nums3(s)
      nums4(s)
      nums5(s)
      nums6(s)
      nums7(s)
      nums8(s)
      nums9(s)
  else:
      nums0(s)
      nums1(s)
      nums2(s)
      nums3(s)
      nums4(s)
      nums5(s)
      nums6(s)
      nums7(s)
      nums8(s)
      nums9(s)
  tmp = set(tmp)
  ans = 0
  # ip = [?,?,2,?,?,5]
  # a  = [1,1,0,1,1,0]
  for i in tmp:
      nums = list(i)
      tmpstr = ""
      jj = 0
      for j in range(len(ip)):
          if a[j] == 1:
              tmpstr += nums[jj]
              jj += 1
          else:
              tmpstr += ip[j]
      if int(tmpstr) % 13 == 5:
          ans += 1
  ans = ans % (10**9 + 1)
  print(ans)
  
problem_description: Statement
  
  Given is a string S. Each character in S is either a digit (`0`, ..., `9`) or
  `?`.
  
  Among the integers obtained by replacing each occurrence of `?` with a digit,
  how many have a remainder of 5 when divided by 13? An integer may begin with
  0.
  
  Since the answer can be enormous, print the count modulo 10^9+7.
samples: [{"input": "??2??5", "output": "768\n    \n\nFor example, 482305, 002865, and 972665 satisfy the condition.\n\n* * *"}, {"input": "?44", "output": "1\n    \n\nOnly 044 satisfies the condition.\n\n* * *"}, {"input": "7?4", "output": "0\n    \n\nWe may not be able to produce an integer satisfying the condition.\n\n* * *"}, {"input": "?6?42???8??2??06243????9??3???7258??5??7???????774????4?1??17???9?5?70???76???", "output": "153716888"}]