A delivery robot is placed at the top-left corner of a city grid and must reach the bottom-right corner. Some streets are locked.
The robot can only move one cell down or one cell right. Open cells are marked with
Count the number of valid routes from the start to the destination. Print the answer modulo
The hidden idea: the number of ways to reach a cell comes from the cell above it and the cell to its left.
The first line contains two integers KaTeX can only parse string typed expression and KaTeX can only parse string typed expression — the number of rows and columns.
Each of the next KaTeX can only parse string typed expression lines contains a string of length KaTeX can only parse string typed expression containing only KaTeX can only parse string typed expression and KaTeX can only parse string typed expression.
Print a single integer — the number of valid routes modulo KaTeX can only parse string typed expression.
Input
3 3
...
.#.
...Output2Example 2:
Input
2 2
.#
..Output1