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)]

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]=( (dp[j]+dp[j-1]) % 1000000007) if a[i][j]=='.' else 0

print((dp[-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)]
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] = ((dp[j] + dp[j - 1]) % 1000000007) if a[i][j] == "." else 0
print((dp[-1]))

-        dp[j] = int(a[i][j] == ".") * (dp[j] + dp[j - 1]) % 1000000007 +        dp[j] = ((dp[j] + dp[j - 1]) % 1000000007) if a[i][j] == "." else 0