#include<cstdio>
const int mod=1e9+7;
long long ans;
int n,m,mp[2010][2010],row[2010],col[2010],dia[5010];
char str[2010];
int add(long long a,long long b)
{
	if(a+b>=mod)	return (a+b)%mod;
	else	return a+b;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
	{
		scanf("%s",str+1);
		for(int j=1;j<=m;++j)
		{
			if(str[j]=='.')	mp[i][j]=0;
			else	mp[i][j]=1;
		}
	}
	int lay=2e3;
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=m;++j)
		{
			if(mp[i][j])
			{
				row[i]=0;
				col[j]=0;
				dia[i-j+lay]=0;
			}
			else
			{
				int tmp=add(add(row[i],col[j]),dia[i-j+lay]);
				if(i==1&&j==1)	++tmp;
				row[i]=add(row[i],tmp);
				col[j]=add(col[j],tmp);
				dia[i-j+lay]=add(dia[i-j+lay],tmp);
				ans=tmp;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define REP(i, n) for(int(i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int(i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int(i) = (n); (i) < (m); ++(i))

// clang-format off
template<class T> inline bool chmax(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
// clang-format on
constexpr int INF = 1e9;

class Timer {
  chrono::time_point<chrono::system_clock> start;

public:
  Timer() { start = chrono::system_clock::now(); }
  double duration() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now() - start).count();
    // return chrono::duration<chrono::milliseconds>(chrono::system_clock::now()- start).count();
  }
};
class xorShift {
  uint32_t x, y, z, w;
  static const double TO_DOUBLE;

public:
  xorShift() {
    x = 123456789;
    y = 362436069;
    z = 521288629;
    w = 88675123;
  }
  xorShift(uint32_t seed) {
    x = seed = 1812433253u * (seed ^ (seed >> 30));
    y = seed = 1812433253u * (seed ^ (seed >> 30)) + 1;
    z = seed = 1812433253u * (seed ^ (seed >> 30)) + 2;
    w = seed = 1812433253u * (seed ^ (seed >> 30)) + 3;
  }
  uint32_t nextInt(uint32_t n) {
    uint32_t t = x ^ (x << 11);
    x = y;
    y = z;
    z = w;
    w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
    return w % n;
  }
  uint32_t nextInt() {
    uint32_t t = x ^ (x << 11);
    x = y;
    y = z;
    z = w;
    return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
  }
  double nextDouble() { return nextInt() * TO_DOUBLE; }
};
const double xorShift::TO_DOUBLE = 1.0 / (1LL << 32);

Timer T;
xorShift rnd;
constexpr double TIME_LIMIT = 1800;
constexpr int N = 20;
int M;
vector<string> s;

struct Solver {
  void first_method() {
    string all_string;
    REP(i, M) { all_string += s[i]; }
    REP(i, N) {
      string line;
      REP(j, N) { line += all_string[i * N + j]; }
      cout << line << endl;
    }
  }
};
int main() {
  int n;
  cin >> n >> M;
  s.resize(M);
  REP(i, M) { cin >> s[i]; }
  Solver solver;
  solver.first_method();
  return 0;
}
