#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n, m;
    ll mod = 1e9 + 7;
    cin >> n >> m;
    vector<string> grid;
    string s;
    for(int i = 0; i < n; i++) {
        cin >> s;
        grid.push_back(s);
    }
    vector<vector<ll>> dp(n, vector<ll>(m, 0));
    vector<vector<ll>> v(n, vector<ll>(m, 0));
    vector<vector<ll>> h(n, vector<ll>(m, 0));
    vector<vector<ll>> d(n, vector<ll>(m, 0));
    
    dp[0][0] = v[0][0] = h[0][0] = d[0][0] = 1;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            if (grid[i][j] == '.') {
                if (i-1 >= 0 && grid[i-1][j] == '.') {
                    dp[i][j] += h[i-1][j];
                    dp[i][j] %= mod;
                }
                if (j-1 >= 0 && grid[i][j-1] == '.') {
                    dp[i][j] += v[i][j-1];
                    dp[i][j] %= mod; 
                }
                if (i-1 >= 0 && j-1 >= 0 && grid[i-1][j-1] == '.') {
                    dp[i][j] += d[i-1][j-1];
                    dp[i][j] %= mod;
                }
                h[i][j] = v[i][j] = d[i][j] = dp[i][j];
                if (i-1 >= 0 && grid[i-1][j] == '.') {
                    h[i][j] += h[i-1][j];
                    h[i][j] %= mod;
                }
                if (j-1 >= 0 && grid[i][j-1] == '.') {
                    v[i][j] += v[i][j-1];
                    v[i][j] %= mod;
                }
                if (i-1 >= 0 && j-1 >= 0 && grid[i-1][j-1] == '.') {
                    d[i][j] += d[i-1][j-1];
                    d[i][j] %= mod;
                }
            }
            // cout << dp[i][j] << " ";
        }
        // cout << endl;
    }
    cout << dp[n-1][m-1] << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int M = 998244353;
const int N = 3001;
long dp[N][N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < N; ++i) {
    dp[i][i] = 1;
  }
  for (int o = 1; o < N; ++o) {
    long s = 0;
    for (int i = 1; i+o < N; ++i) {
      if (2*i <= o+i) s = (s+dp[o+i][2*i])%M;
      dp[o+i][i] = s;
    }
  }
  cout << dp[n][k] << endl;
}
