PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000341. Đếm cách điền chữ số để dư 5 khi chia 13 (Digits Parade)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đếm cách điền chữ số để dư 5 khi chia 13 (Digits Parade)

Digits Parade

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

You are given a string SS of digits 0 through 9 and question marks ?.

Replace each question mark with one digit. Leading zeroes are allowed. Different assignments to question-mark positions count separately.

Count the assignments for which the resulting non-negative integer leaves remainder 55 modulo 1313. Print the answer modulo 109+710^9+7.

Input

One line containing the string SS.

Output

Print the number of valid assignments modulo 109+710^9+7.

Subtasks

  • Subtask 1 (20 points): 1≤∣S∣≤81\le |S|\le 8.
  • Subtask 2 (30 points): 1≤∣S∣≤30001\le |S|\le 3000.
  • Subtask 3 (50 points): 1≤∣S∣≤1051\le |S|\le 10^5.

Examples

Example 1

Input

??2??5

Output

768

Explanation

For example, 482305, 002865, and 972665 each leave remainder 5 modulo 13. Counting every assignment, including leading zeroes, gives 768.

Example 2

Input

?44

Output

1

Explanation

Only replacement ? = 0 makes 044 (value 44), which leaves remainder 5 modulo 13.

Example 3

Input

7?4

Output

0

Explanation

No replacement produces remainder 5 modulo 13.