406549: GYM102439 C Cockroach Racing

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. Cockroach Racingtime limit per test1.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Julia organizes the largest cockroach race ever. It's a fun and exotic job where the main and the only problem is to place cockroaches in the correct order at the start. Once it's done, everything is cockroach gods will. It is known that, chalk written numbers on the cockroaches backs can have leading zeros, and most crucially, the numbers of cockroaches at the start must form an increasing sequence. It's not known who and why came up with this rule. Anyway, we just have to obey. But unfortunately chalk erases easily, so here and there only vague spots remained instead of some digits. Since Julia is a true professional and doesn't want to break the rule, she is trying to restore accidentally erased digits. Let's calculate the sum of all the possible numbers of cockroaches for all possible sequences.

Input

The first line contains two integers $$$n$$$ and $$$m$$$ — the ammount of cockroaches and the length of their numbers. Next $$$n$$$ lines contain numbers patterns. Each pattern is formed using digits '0' to '9' and/or '?' symbol.

$$$$$$1 \le n, m \le 50$$$$$$

Output

Output the sum of all the possible numbers of cockroaches for all the possible sequences modulo $$$10^9+7$$$.

ExamplesInput
2 2
??
??
Output
490050
Input
2 3
4??
??2
Output
6403775
Input
4 1
0
?
4
8
Output
42

加入题单

算法标签: