func_code_string: #include <bits/stdc++.h>   using namespace std;   long long POW(long long A, long long N, long long MOD) {     if (N == 0) return 1 % MOD;     if (N == 1) return A % MOD;     long long tmp = POW(A, N / 2, MOD) % MOD;     if (N % 2)       return ((tmp * tmp) % MOD * A % MOD) % MOD;     else       return (tmp * tmp) % MOD;   }   long long MUL(long long A, long long B, long long MOD) {     long long r = 0;     while (B) {       r = (r + (A * (B % 2) % MOD)) % MOD;       A = (A + A) % MOD;       B /= 2;     }     return r;   }   long long GCD(long long A, long long B) { return B == 0 ? A : GCD(B, A % B); }   int dx[] = {0, -1, 0, 1, 0};   int dy[] = {0, 0, 1, 0, -1};   template <class X, class Y>   bool minimize(X &x, const Y &y) {     X eps = 1e-9;     if (x > y + eps) {       x = y;       return true;     } else       return false;   }   template <class X, class Y>   bool maximize(X &x, const Y &y) {     X eps = 1e-9;     if (x + eps < y) {       x = y;       return true;     } else       return false;   }   template <class T>   T Abs(const T &x) {     return (x < 0 ? -x : x);   }   const int MAXN = 2005;   const int MOD = 1e9 + 7;   void FIXMOD(int &val) {     long long res = val;     if (res < 0) res += 1ll * MOD * MOD;     if (res >= MOD) res %= MOD;     val = res;   }   struct SegmentTree {     int ST[4 * MAXN];     void update(int id, int l, int r, int u, int v, int val) {       if (v < l || r < u) return;       if (u <= l && r <= v) {         ST[id] += val;         ST[id] %= MOD;         FIXMOD(ST[id]);         return;       }       int mid = ((l + r) >> 1);       update((id << 1), l, mid, u, v, val);       update((id << 1 | 1), mid + 1, r, u, v, val);       ST[id] = ST[(id << 1)] + ST[(id << 1 | 1)];       FIXMOD(ST[id]);     }     int get(int id, int l, int r, int u, int v) {       if (v < l || r < u) return 0;       if (u <= l && r <= v) return ST[id];       int mid = ((l + r) >> 1);       int res1 = get((id << 1), l, mid, u, v);       int res2 = get((id << 1 | 1), mid + 1, r, u, v);       return (res1 + res2) % MOD;     }   } IT1[MAXN], IT2[MAXN];   int N, M;   char A[MAXN][MAXN];   int dp[MAXN][MAXN][2];   int sum1[MAXN][MAXN], sum2[MAXN][MAXN], pos1[MAXN][MAXN], pos2[MAXN][MAXN];   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     cin >> N >> M;     for (int i = (1), _b = (N); i <= _b; ++i) {       for (int j = (1), _b = (M); j <= _b; ++j) {         cin >> A[i][j];       }     }     for (int i = (1), _b = (N); i <= _b; ++i) {       for (int j = (1), _b = (M); j <= _b; ++j) {         sum1[i][j] = sum1[i][j - 1] + (A[i][j] ==  R );       }     }     for (int i = (1), _b = (N); i <= _b; ++i) {       for (int j = (1), _b = (M); j <= _b; ++j) {         sum2[i][j] = sum2[i - 1][j] + (A[i][j] ==  R );       }     }     if (N == 1 && M == 1) {       if (A[1][1] ==  . )         cout << 1;       else         cout << 0;       exit(0);     }     dp[1][1][0] = dp[1][1][1] = 1;     IT1[1].update(1, 1, M, 1, 1, 1);     IT2[1].update(1, 1, N, 1, 1, 1);     for (int i = (1), _b = (N); i <= _b; ++i) {       for (int j = (1), _b = (M); j <= _b; ++j) {         int l = 0, r = j;         while (r - l > 1) {           int mid = (l + r) / 2;           int sum = sum1[i][M] - sum1[i][mid];           if (sum <= M - j)             r = mid;           else             l = mid;         }         pos1[i][j] = r;         l = 0, r = i;         while (r - l > 1) {           int mid = (l + r) / 2;           int sum = sum2[N][j] - sum2[mid][j];           if (sum <= N - i)             r = mid;           else             l = mid;         }         pos2[i][j] = r;       }     }     for (int i = (1), _b = (N); i <= _b; ++i) {       for (int j = (1), _b = (M); j <= _b; ++j) {         if (i == 1 && j == 1) continue;         int pos = pos1[i][j];         if (pos != j) {           dp[i][j][1] = IT1[i].get(1, 1, M, pos, j - 1);           IT2[j].update(1, 1, N, i, i, dp[i][j][1]);         }         pos = pos2[i][j];         if (pos != i) {           dp[i][j][0] = IT2[j].get(1, 1, N, pos, i - 1);           IT1[i].update(1, 1, M, j, j, dp[i][j][0]);         }       }     }     cout << (dp[N][M][0] + dp[N][M][1]) % MOD;     return 0;   }   