#include <bits/stdc++.h>
const long long N = 2e3 + 10;
const long long mod = 1e9 + 7;
const long long inf = 0x3f3f3f3f;
const double eps = 1e-8;
const double pi = acos(-1);
using namespace std;
namespace geo {
long long sgn(double x) {
  if (fabs(x) < eps) return 0;
  if (x < 0)
    return -1;
  else
    return 1;
}
struct point {
  double x, y;
  point() {}
  point(double xx, double yy) {
    x = xx;
    y = yy;
  }
  point operator+(point b) { return point(x + b.x, y + b.y); }
  point operator-(point b) { return point(x - b.x, y - b.y); }
  double operator^(point b) { return x * b.y - y * b.x; }
  double operator*(point b) { return x * b.x + y * b.y; }
  point operator*(double b) { return point(x * b, y * b); }
  double gettan() { return atan2(y, x); }
  void read() { scanf("%lf%lf", &x, &y); }
};
struct line {
  point s, e, l;
  line() {}
  line(point ss, point ee) {
    s = ss;
    e = ee;
    l = e - s;
  }
  void read() {
    s.read(), e.read();
    l = e - s;
  }
  double gettan() { return atan2(e.y - s.y, e.x - s.x); }
};
struct circle {
  point o;
  double r;
  circle() {}
  circle(point oo, double rr) {
    o = oo;
    r = rr;
  }
};
double dis2(point a, point b) { return (b - a) * (b - a); }
double dis(point a, point b) { return sqrt(dis2(a, b)); }
bool onseg(line l, point p) {
  bool x1 = sgn((l.s - p) ^ (l.e - p)) == 0;
  bool x2 = sgn((l.s - p) * (l.e - p)) <= 0;
  return x1 && x2;
}
point spin(point p, double a) {
  return point(p.x * cos(a) - p.y * sin(a), p.y * cos(a) + p.x * sin(a));
}
double len(point a) { return sqrt(a * a); }
point projection(line l, point p) {
  return l.s + l.l * ((l.l * (p - l.s)) / ((l.l) * (l.l)));
}
bool judge(line l1, line l2) {
  point a = l1.s, b = l1.e, c = l2.s, d = l2.e;
  bool x1 = sgn((c - a) ^ l1.l) * sgn((d - a) ^ l1.l) <= 0;
  bool x2 = sgn((a - c) ^ l2.l) * sgn((b - c) ^ l2.l) <= 0;
  return x1 && x2 && max(l1.s.x, l1.e.x) >= min(l2.s.x, l2.e.x) &&
         max(l2.s.x, l2.e.x) >= min(l1.s.x, l1.e.x) &&
         max(l1.s.y, l1.e.y) >= min(l2.s.y, l2.e.y) &&
         max(l2.s.y, l2.e.y) >= min(l1.s.y, l1.e.y);
}
point getcross(line l1, line l2) {
  double s1 = ((l2.s - l1.s) ^ (l2.e - l1.s));
  double s2 = ((l2.e - l1.e) ^ (l2.s - l1.e));
  if (s1 + s2 == 0) return point{inf, inf};
  return l1.s + l1.l * (s1 / (s1 + s2));
}
double dis_pl(point p, line l) {
  point v = p - l.s;
  double ans = (v ^ l.l) / sqrt(l.l * l.l);
  return fabs(ans);
}
double askarea(point d[], long long n) {
  d[n + 1] = d[1];
  double area = 0;
  for (long long i = 1; i <= n; i++) area += (d[i] ^ d[i + 1]);
  area /= 2;
  return fabs(area);
}
long long cmp(line a, line b) {
  double t1 = a.gettan(), t2 = b.gettan();
  if (sgn(t1 - t2) == 0) return (a.l ^ (b.e - a.s)) > 0;
  return t1 < t2;
}
long long onright(line a, line b, line c) {
  point p = getcross(b, c);
  return (a.l ^ (p - a.s)) < 0;
}
void hpi(line li[], long long n) {
  line que[N];
  sort(li + 1, li + n + 1, cmp);
  long long l = 1, r = 1, cnt = 0, i;
  for (i = 1; i < n; i++)
    if (sgn(li[i].gettan() - li[i + 1].gettan())) li[++cnt] = li[i];
  li[++cnt] = li[n];
  for (i = 1; i <= cnt; i++) {
    while (r - l > 1 && onright(li[i], que[r - 1], que[r - 2])) r--;
    while (r - l > 1 && onright(li[i], que[l], que[l + 1])) l++;
    que[r++] = li[i];
  }
  while (r - l > 1 && onright(que[l], que[r - 1], que[r - 2])) r--;
  while (r - l > 1 && onright(que[r - 1], que[l], que[l + 1])) l++;
}
}  // namespace geo
char a[N][N];
long long sumd[N][N] = {0}, sumr[N][N] = {0}, dp[N][N][2] = {0}, d[N][N] = {0},
          r[N][N] = {0};
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m, i, j;
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> a[i] + 1;
    for (j = 1; j <= m; j++)
      if (a[i][j] == 'R') d[i][j] = r[i][j] = 1;
  }
  for (i = n; i >= 1; i--)
    for (j = m; j >= 1; j--) {
      d[i][j] += d[i + 1][j];
      r[i][j] += r[i][j + 1];
    }
  dp[n][m][0] = dp[n][m][1] = sumd[n][m] = sumr[n][m] = 1;
  if (n == 1 && m == 1) {
    cout << 1 << endl;
    return 0;
  }
  for (i = n; i >= 1; i--)
    for (j = m; j >= 1; j--) {
      if (i == n && j == m) continue;
      dp[i][j][0] = (sumd[i][j + 1] - sumd[i][m - r[i][j + 1] + 1] + mod) % mod;
      dp[i][j][1] = (sumr[i + 1][j] - sumr[n - d[i + 1][j] + 1][j] + mod) % mod;
      sumr[i][j] = (sumr[i + 1][j] + dp[i][j][0]) % mod;
      sumd[i][j] = (sumd[i][j + 1] + dp[i][j][1]) % mod;
    }
  cout << (dp[1][1][0] + dp[1][1][1]) % mod << endl;
  return 0;
}

### Prompt

Please create a solution in Cpp to the following problem:

You are at the top left cell (1, 1) of an n × m labyrinth. Your goal is to get to the bottom right cell (n, m). You can only move right or down, one cell per step. Moving right from a cell (x, y) takes you to the cell (x, y + 1), while moving down takes you to the cell (x + 1, y).

Some cells of the labyrinth contain rocks. When you move to a cell with rock, the rock is pushed to the next cell in the direction you're moving. If the next cell contains a rock, it gets pushed further, and so on.

The labyrinth is surrounded by impenetrable walls, thus any move that would put you or any rock outside of the labyrinth is illegal.

Count the number of different legal paths you can take from the start to the goal modulo 10^9 + 7. Two paths are considered different if there is at least one cell that is visited in one path, but not visited in the other.

Input

The first line contains two integers n, m — dimensions of the labyrinth (1 ≤ n, m ≤ 2000).

Next n lines describe the labyrinth. Each of these lines contains m characters. The j-th character of the i-th of these lines is equal to "R" if the cell (i, j) contains a rock, or "." if the cell (i, j) is empty.

It is guaranteed that the starting cell (1, 1) is empty.

Output

Print a single integer — the number of different legal paths from (1, 1) to (n, m) modulo 10^9 + 7.

Examples

Input


1 1
.


Output


1


Input


2 3
...
..R


Output


0


Input


4 4
...R
.RR.
.RR.
R...


Output


4

Note

In the first sample case we can't (and don't have to) move, hence the only path consists of a single cell (1, 1).

In the second sample case the goal is blocked and is unreachable.

Illustrations for the third sample case can be found here: <https://assets.codeforces.com/rounds/1225/index.html>

### Response

```cpp
#include <bits/stdc++.h>
const long long N = 2e3 + 10;
const long long mod = 1e9 + 7;
const long long inf = 0x3f3f3f3f;
const double eps = 1e-8;
const double pi = acos(-1);
using namespace std;
namespace geo {
long long sgn(double x) {
  if (fabs(x) < eps) return 0;
  if (x < 0)
    return -1;
  else
    return 1;
}
struct point {
  double x, y;
  point() {}
  point(double xx, double yy) {
    x = xx;
    y = yy;
  }
  point operator+(point b) { return point(x + b.x, y + b.y); }
  point operator-(point b) { return point(x - b.x, y - b.y); }
  double operator^(point b) { return x * b.y - y * b.x; }
  double operator*(point b) { return x * b.x + y * b.y; }
  point operator*(double b) { return point(x * b, y * b); }
  double gettan() { return atan2(y, x); }
  void read() { scanf("%lf%lf", &x, &y); }
};
struct line {
  point s, e, l;
  line() {}
  line(point ss, point ee) {
    s = ss;
    e = ee;
    l = e - s;
  }
  void read() {
    s.read(), e.read();
    l = e - s;
  }
  double gettan() { return atan2(e.y - s.y, e.x - s.x); }
};
struct circle {
  point o;
  double r;
  circle() {}
  circle(point oo, double rr) {
    o = oo;
    r = rr;
  }
};
double dis2(point a, point b) { return (b - a) * (b - a); }
double dis(point a, point b) { return sqrt(dis2(a, b)); }
bool onseg(line l, point p) {
  bool x1 = sgn((l.s - p) ^ (l.e - p)) == 0;
  bool x2 = sgn((l.s - p) * (l.e - p)) <= 0;
  return x1 && x2;
}
point spin(point p, double a) {
  return point(p.x * cos(a) - p.y * sin(a), p.y * cos(a) + p.x * sin(a));
}
double len(point a) { return sqrt(a * a); }
point projection(line l, point p) {
  return l.s + l.l * ((l.l * (p - l.s)) / ((l.l) * (l.l)));
}
bool judge(line l1, line l2) {
  point a = l1.s, b = l1.e, c = l2.s, d = l2.e;
  bool x1 = sgn((c - a) ^ l1.l) * sgn((d - a) ^ l1.l) <= 0;
  bool x2 = sgn((a - c) ^ l2.l) * sgn((b - c) ^ l2.l) <= 0;
  return x1 && x2 && max(l1.s.x, l1.e.x) >= min(l2.s.x, l2.e.x) &&
         max(l2.s.x, l2.e.x) >= min(l1.s.x, l1.e.x) &&
         max(l1.s.y, l1.e.y) >= min(l2.s.y, l2.e.y) &&
         max(l2.s.y, l2.e.y) >= min(l1.s.y, l1.e.y);
}
point getcross(line l1, line l2) {
  double s1 = ((l2.s - l1.s) ^ (l2.e - l1.s));
  double s2 = ((l2.e - l1.e) ^ (l2.s - l1.e));
  if (s1 + s2 == 0) return point{inf, inf};
  return l1.s + l1.l * (s1 / (s1 + s2));
}
double dis_pl(point p, line l) {
  point v = p - l.s;
  double ans = (v ^ l.l) / sqrt(l.l * l.l);
  return fabs(ans);
}
double askarea(point d[], long long n) {
  d[n + 1] = d[1];
  double area = 0;
  for (long long i = 1; i <= n; i++) area += (d[i] ^ d[i + 1]);
  area /= 2;
  return fabs(area);
}
long long cmp(line a, line b) {
  double t1 = a.gettan(), t2 = b.gettan();
  if (sgn(t1 - t2) == 0) return (a.l ^ (b.e - a.s)) > 0;
  return t1 < t2;
}
long long onright(line a, line b, line c) {
  point p = getcross(b, c);
  return (a.l ^ (p - a.s)) < 0;
}
void hpi(line li[], long long n) {
  line que[N];
  sort(li + 1, li + n + 1, cmp);
  long long l = 1, r = 1, cnt = 0, i;
  for (i = 1; i < n; i++)
    if (sgn(li[i].gettan() - li[i + 1].gettan())) li[++cnt] = li[i];
  li[++cnt] = li[n];
  for (i = 1; i <= cnt; i++) {
    while (r - l > 1 && onright(li[i], que[r - 1], que[r - 2])) r--;
    while (r - l > 1 && onright(li[i], que[l], que[l + 1])) l++;
    que[r++] = li[i];
  }
  while (r - l > 1 && onright(que[l], que[r - 1], que[r - 2])) r--;
  while (r - l > 1 && onright(que[r - 1], que[l], que[l + 1])) l++;
}
}  // namespace geo
char a[N][N];
long long sumd[N][N] = {0}, sumr[N][N] = {0}, dp[N][N][2] = {0}, d[N][N] = {0},
          r[N][N] = {0};
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m, i, j;
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> a[i] + 1;
    for (j = 1; j <= m; j++)
      if (a[i][j] == 'R') d[i][j] = r[i][j] = 1;
  }
  for (i = n; i >= 1; i--)
    for (j = m; j >= 1; j--) {
      d[i][j] += d[i + 1][j];
      r[i][j] += r[i][j + 1];
    }
  dp[n][m][0] = dp[n][m][1] = sumd[n][m] = sumr[n][m] = 1;
  if (n == 1 && m == 1) {
    cout << 1 << endl;
    return 0;
  }
  for (i = n; i >= 1; i--)
    for (j = m; j >= 1; j--) {
      if (i == n && j == m) continue;
      dp[i][j][0] = (sumd[i][j + 1] - sumd[i][m - r[i][j + 1] + 1] + mod) % mod;
      dp[i][j][1] = (sumr[i + 1][j] - sumr[n - d[i + 1][j] + 1][j] + mod) % mod;
      sumr[i][j] = (sumr[i + 1][j] + dp[i][j][0]) % mod;
      sumd[i][j] = (sumd[i][j + 1] + dp[i][j][1]) % mod;
    }
  cout << (dp[1][1][0] + dp[1][1][1]) % mod << endl;
  return 0;
}

```