#include #include using namespace std; using ll = long long; using mint = atcoder::modint998244353; template istream& operator >> (istream& is, vector& vec) { for(T& x : vec) is >> x; return is; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int h, w; cin >> h >> w; vector A(h); cin >> A; vector dp(w, vector(w)); dp[0][1] = 1; for(int y = 0; y < h; y++){ for(int x2 = 0; x2 < w; x2++){ for(int x1 = 0; x1 < x2; x1++){ if(A[y][x1] == '#' || A[y][x2] == '#') dp[x1][x2] = 0; if(x1 + 1 < x2 && A[y][x1 + 1] == '.') dp[x1 + 1][x2] += dp[x1][x2]; } } for(int x1 = 0; x1 < w; x1++){ for(int x2 = x1 + 1; x2 < w; x2++){ if(x2 + 1 < w && A[y][x2 + 1] == '.') dp[x1][x2 + 1] += dp[x1][x2]; } } } cout << dp[w - 2][w - 1].val() << '\n'; }