import sys # sys.setrecursionlimit(200005) # sys.set_int_max_str_digits(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] # inf = -1-(-1 << 31) inf = -1-(-1 << 62) # md = 10**9+7 md = 998244353 from collections import Counter h, w = LI() ss = [[c == "#" for c in SI()] for _ in range(h)] n = min(h, w) def push(i, j, p, q, val): if i == p or i == h or j == w or p == h or q == w or ss[i][j] or ss[p][q]: return dp[i][p] += val dp[i][p] %= md dp = [[0]*h for _ in range(h)] dp[0][1] = 1 for d in range(1, h+w-3): pre, dp = dp, [[0]*h for _ in range(h)] for p in range(h): q = d-p if q < 0: break if q >= w: continue for i in range(p): j = d-i if j < 0: break if j >= w: continue push(i+1, j, p+1, q, pre[i][p]) push(i+1, j, p, q+1, pre[i][p]) push(i, j+1, p+1, q, pre[i][p]) push(i, j+1, p, q+1, pre[i][p]) # p2D(dp) ans = 0 for p in range(h): for i in range(p): ans += dp[i][p] ans %= md print(ans)