문제
Bessie has become an artist and is creating paintings of caves! Her current work in progress is a grid of height
Suppose that square
Find the number of different paintings Bessie can make modulo
SCORING:
Test cases 1-5 satisfy
N,M\le 10. Test cases 6-15 satisfy no additional constraints.
Problem credits: Daniel Zhang
입력
The first line contains two space-separated integers
The next
출력
A single integer: the number of paintings satisfying the constraint modulo
예제1
4 9
#########
#...#...#
#.#...#.#
#########
9
If a square in the second row is filled with water, then all empty squares must be filled with water. Otherwise, assume that no such squares are filled with water. Then Bessie can choose to fill any subset of the three horizontally contiguous regions of empty squares in the third row. Thus, the number of paintings is equal to