H, W = list(map(int, input().split()))

STAGE = [list(eval(input())) for _ in range(H)]



dp = [[0 for _ in range(W)] for _ in range(H)]

dp[0][0] = 1



MOD = 10 ** 9 + 7



for y in range(H):

	for x in range(W):

		if y + 1 < H and STAGE[y + 1][x] == ".":

			dp[y + 1][x] += dp[y][x]

			if MOD < dp[y + 1][x]:

				dp[y + 1][x] -= MOD

		if x + 1 < W and STAGE[y][x + 1] == ".":

			dp[y][x + 1] += dp[y][x]

			if MOD < dp[y][x + 1]:

				dp[y][x + 1] -= MOD



print((dp[-1][-1]))

H, W = list(map(int, input().split()))

STAGE = [list(eval(input())) for _ in range(H)]



dp = [[0 for _ in range(W)] for _ in range(H)]

dp[0][0] = 1



MOD = 10 ** 9 + 7



for y in range(H):

	for x in range(W):

		if y + 1 < H and STAGE[y + 1][x] == ".":

			dp[y + 1][x] += dp[y][x] % MOD

		if x + 1 < W and STAGE[y][x + 1] == ".":

			dp[y][x + 1] += dp[y][x] % MOD



print((dp[-1][-1] % MOD))

H, W = list(map(int, input().split()))
STAGE = [list(eval(input())) for _ in range(H)]
dp = [[0 for _ in range(W)] for _ in range(H)]
dp[0][0] = 1
MOD = 10**9 + 7
for y in range(H):
    for x in range(W):
        if y + 1 < H and STAGE[y + 1][x] == ".":
            dp[y + 1][x] += dp[y][x]
            if MOD < dp[y + 1][x]:
                dp[y + 1][x] -= MOD
        if x + 1 < W and STAGE[y][x + 1] == ".":
            dp[y][x + 1] += dp[y][x]
            if MOD < dp[y][x + 1]:
                dp[y][x + 1] -= MOD
print((dp[-1][-1]))

H, W = list(map(int, input().split()))
STAGE = [list(eval(input())) for _ in range(H)]
dp = [[0 for _ in range(W)] for _ in range(H)]
dp[0][0] = 1
MOD = 10**9 + 7
for y in range(H):
    for x in range(W):
        if y + 1 < H and STAGE[y + 1][x] == ".":
            dp[y + 1][x] += dp[y][x] % MOD
        if x + 1 < W and STAGE[y][x + 1] == ".":
            dp[y][x + 1] += dp[y][x] % MOD
print((dp[-1][-1] % MOD))

-            dp[y + 1][x] += dp[y][x] -            if MOD < dp[y + 1][x]: -                dp[y + 1][x] -= MOD +            dp[y + 1][x] += dp[y][x] % MOD -            dp[y][x + 1] += dp[y][x] -            if MOD < dp[y][x + 1]: -                dp[y][x + 1] -= MOD -print((dp[-1][-1])) +            dp[y][x + 1] += dp[y][x] % MOD +print((dp[-1][-1] % MOD))