Walk and jump

Given an n×mn \times m map with obstacles, in how many ways can we go from the upper-left corner to the lower-right corner? We can only walk (move to the cell immediately to the right or below), or jump (move to the cell two positions to the right or below, but only by jumping an obstacle). We can never visit any obstacle.

Input

Input consists of several cases. Every case begins with nn and mm, followed by nn rows with cc characters each. The cells with an obstacle have an ‘X’, and the empty cells a period. The initial and final cells are always empty. Assume that both nn and mm are between 2 and 100.

Output

For every case, print the number of ways to go from the beginning to the end, as explained above. Since this number can be very large, make the computations modulo 108+710^8 + 7.

Problem information

Author: Unknown
Translator: Salvador Roura

Generation: 2026-01-25T12:11:59.006Z

© Jutge.org, 2006–2026.
https://jutge.org