func_code_string: #include <bits/stdc++.h>   template <typename T>   void rd(T& x) {     long long f = 0, c;     while ((c = getchar()) < 48 || 57 < c) f ^= !(c ^ 45);     x = (c & 15);     while (47 < (c = getchar()) && c < 58) x = x * 10 + (c & 15);     if (f) x = -x;   }   template <typename T>   inline void pt(T x) {     if (x < 0) x = -x, putchar( - );     if (x > 9) pt(x / 10);     putchar(x % 10 + 48);   }   template <typename T>   inline void pt(T x, long long c) {     pt(x), putchar(c);   }   template <typename T>   inline T max(const T& x, const T& y) {     return x < y ? y : x;   }   template <typename T>   inline T min(const T& x, const T& y) {     return x < y ? x : y;   }   const long long N = 2005, P = 1000000007;   long long n, m, f[2][N][N], sum[N][N];   char s[N][N];   long long getsum(long long a, long long b, long long c, long long d) {     if (a > c || b > d) return 0;     return sum[c][d] - sum[c][b - 1] - sum[a - 1][d] + sum[a - 1][b - 1];   }   long long getf0(long long a, long long b, long long c, long long d) {     if (a > c || b > d) return 0;     return f[0][c][d] - f[0][c][b - 1] - f[0][a - 1][d] + f[0][a - 1][b - 1];   }   long long getf1(long long a, long long b, long long c, long long d) {     if (a > c || b > d) return 0;     return f[1][c][d] - f[1][c][b - 1] - f[1][a - 1][d] + f[1][a - 1][b - 1];   }   signed main() {     rd(n), rd(m);     for (long long i = (1); i <= (n); ++i) scanf( %s , s[i] + 1);     if (s[n][m] ==  R ) {       puts( 0 );       return 0;     }     if (n == 1 && m == 1) {       puts( 1 );       return 0;     }     for (long long i = (1); i <= (n); ++i)       for (long long j = (1); j <= (m); ++j)         sum[i][j] =             sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1] + (s[i][j] ==  R );     f[0][1][1] = 1;     f[1][1][1] = 1;     for (long long i = (1); i <= (n); ++i)       for (long long j = (1); j <= (m); ++j) {         long long l = 1, r = i, ans = i;         while (l <= r) {           long long mid = (l + r) >> 1;           if (getsum(mid + 1, j, n, j) <= n - i)             ans = mid, r = mid - 1;           else             l = mid + 1;         }         (f[1][i][j] += getf0(ans, j, i - 1, j)) %= P;         l = 1, r = j, ans = j;         while (l <= r) {           long long mid = (l + r) >> 1;           if (getsum(i, mid + 1, i, m) <= m - j)             ans = mid, r = mid - 1;           else             l = mid + 1;         }         (f[0][i][j] += getf1(i, ans, i, j - 1)) %= P;         (f[0][i][j] += f[0][i][j - 1] + f[0][i - 1][j] - f[0][i - 1][j - 1]) %= P;         (f[1][i][j] += f[1][i][j - 1] + f[1][i - 1][j] - f[1][i - 1][j - 1]) %= P;       }     pt(((getf0(n, m, n, m) + getf1(n, m, n, m)) % P + P) % P,   n );     return 0;   }   