import sys

from collections import deque

sys.setrecursionlimit(10**9)

INF=10**18

MOD=10**9+7

def input(): return sys.stdin.readline().rstrip()



def main():

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

    a=[[] for _ in range(H+2)]

    a[0]=a[H+1]='#'*(W+2)

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

        a[i]='#'+eval(input())+'#'

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

    dp[1][1]=1

    que=deque()

    que.append((1,1))

    dx=[1,0]

    dy=[0,1]

    used=[[False]*(W*2) for _ in range(H+2)]

    used[1][1]=True

    while que:

        y,x=que.popleft()

        for k in range(2):

            ny,nx=y+dy[k],x+dx[k]

            if a[ny][nx]=='.':

                dp[ny][nx]+=dp[y][x]

                dp[ny][nx]%=MOD

                if not used[ny][nx]:

                    que.append((ny,nx))

                    used[ny][nx]=True

    print((dp[H][W]))



if __name__ == '__main__':

    main()

import sys

from collections import deque

sys.setrecursionlimit(10**9)

INF=10**18

MOD=10**9+7

def input(): return sys.stdin.readline().rstrip()



def main():

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

    a=[[] for _ in range(H+2)]

    a[0]=a[H+1]='#'*(W+2)

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

        a[i]='#'+eval(input())+'#'

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

    for column in range(1,H+1):

        for row in range(1,W+1):

            if column==row==1:

                dp[column][row]=1

            elif a[column][row]=='.':

                dp[column][row]=(dp[column-1][row]+dp[column][row-1])%MOD

    print((dp[H][W]))



if __name__ == '__main__':

    main()

import sys
from collections import deque

sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7


def input():
    return sys.stdin.readline().rstrip()


def main():
    H, W = list(map(int, input().split()))
    a = [[] for _ in range(H + 2)]
    a[0] = a[H + 1] = "#" * (W + 2)
    for i in range(1, H + 1):
        a[i] = "#" + eval(input()) + "#"
    dp = [[0] * (W + 2) for _ in range(H + 2)]
    dp[1][1] = 1
    que = deque()
    que.append((1, 1))
    dx = [1, 0]
    dy = [0, 1]
    used = [[False] * (W * 2) for _ in range(H + 2)]
    used[1][1] = True
    while que:
        y, x = que.popleft()
        for k in range(2):
            ny, nx = y + dy[k], x + dx[k]
            if a[ny][nx] == ".":
                dp[ny][nx] += dp[y][x]
                dp[ny][nx] %= MOD
                if not used[ny][nx]:
                    que.append((ny, nx))
                    used[ny][nx] = True
    print((dp[H][W]))


if __name__ == "__main__":
    main()

import sys
from collections import deque

sys.setrecursionlimit(10**9)
INF = 10**18
MOD = 10**9 + 7


def input():
    return sys.stdin.readline().rstrip()


def main():
    H, W = list(map(int, input().split()))
    a = [[] for _ in range(H + 2)]
    a[0] = a[H + 1] = "#" * (W + 2)
    for i in range(1, H + 1):
        a[i] = "#" + eval(input()) + "#"
    dp = [[0] * (W + 2) for _ in range(H + 2)]
    for column in range(1, H + 1):
        for row in range(1, W + 1):
            if column == row == 1:
                dp[column][row] = 1
            elif a[column][row] == ".":
                dp[column][row] = (dp[column - 1][row] + dp[column][row - 1]) % MOD
    print((dp[H][W]))


if __name__ == "__main__":
    main()

-    dp[1][1] = 1 -    que = deque() -    que.append((1, 1)) -    dx = [1, 0] -    dy = [0, 1] -    used = [[False] * (W * 2) for _ in range(H + 2)] -    used[1][1] = True -    while que: -        y, x = que.popleft() -        for k in range(2): -            ny, nx = y + dy[k], x + dx[k] -            if a[ny][nx] == ".": -                dp[ny][nx] += dp[y][x] -                dp[ny][nx] %= MOD -                if not used[ny][nx]: -                    que.append((ny, nx)) -                    used[ny][nx] = True +    for column in range(1, H + 1): +        for row in range(1, W + 1): +            if column == row == 1: +                dp[column][row] = 1 +            elif a[column][row] == ".": +                dp[column][row] = (dp[column - 1][row] + dp[column][row - 1]) % MOD