h, w = list(map(int, input().split()))

a=[ list(eval(input())) for _ in range(h)]

mod=int((1e9)+7)

dp=[ [0]*w for _ in range(h+1)]

dp[0][0]=1

for i in range(1,h+1):

    dp[i][0]=int(dp[i-1][0]==1)*int(a[i-1][0]=='.')

    for j in range(1,w):

        dp[i][j]=(dp[i-1][j]+dp[i][j-1])*int(not a[i-1][j]=='#') % mod

print((dp[-1][-1]))
h, w = list(map(int, input().split()))

a=[ list(eval(input())) for _ in range(h)]

dp=[1]+[0]*(w-1)

for i in range(h):

    dp[0]=int(dp[0]==1 and a[i][0]=='.')

    for j in range(1,w): dp[j]=(int(a[i][j]=='.')*(dp[j]+dp[j-1]) % 1000000007 )

print((dp[-1]))
h, w = list(map(int, input().split()))
a = [list(eval(input())) for _ in range(h)]
mod = int((1e9) + 7)
dp = [[0] * w for _ in range(h + 1)]
dp[0][0] = 1
for i in range(1, h + 1):
    dp[i][0] = int(dp[i - 1][0] == 1) * int(a[i - 1][0] == ".")
    for j in range(1, w):
        dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) * int(not a[i - 1][j] == "#") % mod
print((dp[-1][-1]))

h, w = list(map(int, input().split()))
a = [list(eval(input())) for _ in range(h)]
dp = [1] + [0] * (w - 1)
for i in range(h):
    dp[0] = int(dp[0] == 1 and a[i][0] == ".")
    for j in range(1, w):
        dp[j] = int(a[i][j] == ".") * (dp[j] + dp[j - 1]) % 1000000007
print((dp[-1]))

-mod = int((1e9) + 7) -dp = [[0] * w for _ in range(h + 1)] -dp[0][0] = 1 -for i in range(1, h + 1): -    dp[i][0] = int(dp[i - 1][0] == 1) * int(a[i - 1][0] == ".") +dp = [1] + [0] * (w - 1) +for i in range(h): +    dp[0] = int(dp[0] == 1 and a[i][0] == ".") -        dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) * int(not a[i - 1][j] == "#") % mod -print((dp[-1][-1])) +        dp[j] = int(a[i][j] == ".") * (dp[j] + dp[j - 1]) % 1000000007 +print((dp[-1]))