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

a = [list(eval(input())) for i in range(H)]



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



flagH = 0

flagW = 0



for i in range(H):

  if a[i][0]=="." and flagH==0:

    dp[i][0]=1

  else:

    dp[i][0]=0

    flagH=1



for j in range(W):

  if a[0][j]=="." and flagW==0:

    dp[0][j]=1

  else:

    dp[0][j]=0

    flagW=1



for i in range(1,H):

  for j in range(1,W):

    if a[i][j]==".":

      dp[i][j]=dp[i-1][j]+dp[i][j-1]



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

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

MOD = 10**9 + 7



dp = [[0]*w for i in range(h)]

dp[0][0] = 1



for i in range(h):

    for j in range(w):

        if a[i][j] == ".":

            if i+1 < h:

                dp[i+1][j] += dp[i][j]

                dp[i+1][j] %= MOD

            if j+1 < w:

                dp[i][j+1] += dp[i][j]

                dp[i][j+1] %= MOD



print((dp[-1][-1]))
H, W = list(map(int, input().split()))
a = [list(eval(input())) for i in range(H)]
dp = [[0] * (W) for i in range(H)]
flagH = 0
flagW = 0
for i in range(H):
    if a[i][0] == "." and flagH == 0:
        dp[i][0] = 1
    else:
        dp[i][0] = 0
        flagH = 1
for j in range(W):
    if a[0][j] == "." and flagW == 0:
        dp[0][j] = 1
    else:
        dp[0][j] = 0
        flagW = 1
for i in range(1, H):
    for j in range(1, W):
        if a[i][j] == ".":
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1]
print((dp[H - 1][W - 1] % 1000000007))

h, w = list(map(int, input().split()))
a = [eval(input()) for i in range(h)]
MOD = 10**9 + 7
dp = [[0] * w for i in range(h)]
dp[0][0] = 1
for i in range(h):
    for j in range(w):
        if a[i][j] == ".":
            if i + 1 < h:
                dp[i + 1][j] += dp[i][j]
                dp[i + 1][j] %= MOD
            if j + 1 < w:
                dp[i][j + 1] += dp[i][j]
                dp[i][j + 1] %= MOD
print((dp[-1][-1]))

-H, W = list(map(int, input().split())) -a = [list(eval(input())) for i in range(H)] -dp = [[0] * (W) for i in range(H)] -flagH = 0 -flagW = 0 -for i in range(H): -    if a[i][0] == "." and flagH == 0: -        dp[i][0] = 1 -    else: -        dp[i][0] = 0 -        flagH = 1 -for j in range(W): -    if a[0][j] == "." and flagW == 0: -        dp[0][j] = 1 -    else: -        dp[0][j] = 0 -        flagW = 1 -for i in range(1, H): -    for j in range(1, W): +h, w = list(map(int, input().split())) +a = [eval(input()) for i in range(h)] +MOD = 10**9 + 7 +dp = [[0] * w for i in range(h)] +dp[0][0] = 1 +for i in range(h): +    for j in range(w): -            dp[i][j] = dp[i - 1][j] + dp[i][j - 1] -print((dp[H - 1][W - 1] % 1000000007)) +            if i + 1 < h: +                dp[i + 1][j] += dp[i][j] +                dp[i + 1][j] %= MOD +            if j + 1 < w: +                dp[i][j + 1] += dp[i][j] +                dp[i][j + 1] %= MOD +print((dp[-1][-1]))