#include<bits/stdc++.h>
using namespace std;

int debug = 1;
int test = 1;

#define printa(a) {for(auto i:a){cout<<i<<" ";} cout<<endl;}
// print debug -> printd()   ||  print for ans -> printa()
#define printd(a) if(debug){cout<<"printing-> ";  for(auto i:a){cout<<setw(2)<<i<<" ";} cout<<endl;}
#define run if(debug)cout<<__LINE__<<endl;
#define Clear( a, b ) memset( a, b, sizeof( a ) )

#define swapp(v) swap(v[0],v[v.size()-1])

#define vvi vector<vector<ll int> >
#define vi vector<int>
#define ff first
#define ss second
#define no cout<<"NO"<<endl;
#define yes cout<<"YES"<<endl;
#define lb lower_bound
#define ub upper_bound

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)

#define in insert
#define mp make_pair
#define pb push_back
#define pii  pair<ll int,ll int>
#define piii pair<ll int,pair<ll int,ll int> >
#define piiii pair<pair<ll int,ll int>,pair<ll int,ll int> >

#define ll long long

long double pi = 3.14159265358979323846;

#define binf 10000000000050000
#define llinf 1000000000005000000
#define inf 1000050000
#define MOD 1000000007
#define abs llabs
#define BOOST ios::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);

inline ll int min2(ll a, ll b)
{
    if (a < b) {return a;}
    return b;
}
inline long long  max3(long long  a, long long  b, long long  c) {return (a) > (b) ? ((a) > (c) ? (a) : (c)) : ((b) > (c) ? (b) : (c));}
inline long long  min3(long long  a, long long b, long long c) {return (a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b) : (c));}
//########################################################//
// for modinverse calculation  // here MOD = 10^9+7
ll extgcd(ll a, ll b, ll &x, ll &y) {                     // ExtGCD
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}

inline ll mod(ll a, ll m) {                               // mod a wrt b
    return (a % m + m) % m;
}

ll modinv(ll a) {                                         // mod inverse a wrt 10^9+7
    ll x, y;
    extgcd(a, MOD, x, y);
    return mod(x, MOD);
}
//#########################################################//
// GCD
ll gcd(ll u, ll v) {
    ll r;
    while (0 != v) {
        r = u % v; u = v; v = r;
    }
    return u;
}
//###########################################################//
// LCM
ll lcm(ll u, ll v) {
    return u / gcd(u, v) * v;
}
//##########################################################//
//void floyd_warshall(ll n){
//  rep(i,n)rep(j,n)rep(k,n)d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
//}
//##########################################################//
// Get all factors  // cnt in 'a' array
void get_all_factors(int a[], ll int n) {
    ll int w = sqrt(n);
    for (int i = 1; i <= w; i++) {
        if (n % i == 0) {  a[i]++;   a[n / i]++;  }
    }
    ll int x = ceil(sqrt(n)); if (sqrt(n) == ceil(sqrt(n)))  a[(int)sqrt(n)]--;
}
//#################################//
// COMPUTE nCr
ll int memo[100000][110] = {0};
ll C(ll n, ll r)
{
    if (r == 0 || r == n)
        return 1;
    if (memo[n][r] != -1) return memo[n][r];
    return memo[n][r] = ( C(n - 1, r - 1) % MOD + C(n - 1, r) % MOD ) % MOD;
}
//##########################################################//
// Debugging
int valid(string s, int i) { if (s == "lol" or i == -inf) {   return 0;  }  return 1; }
void status(string s1 = "lol", ll int i1 = -inf, string s2 = "lol", ll int i2 = -inf, string s3 = "lol", ll int i3 = -inf) {
    if (debug) {
        if (valid(s1, i1)) {  cout << s1 << "=" << i1 << "  ";  }
        if (valid(s2, i2)) {  cout << s2 << "=" << i2 << "  ";  }
        if (valid(s3, i3)) {  cout << s3 << "=" << i3 << "  ";  }
        cout << endl;
    }
}

//###########################################//
// Compute power with or without MOD

ll int poww(ll x, ll y) {ll res = 1; while (y) {if (y & 1)res = res * x; y = y >> 1; x = x * x;} return res;}
ll int powm(ll x, ll y, ll m = MOD) {x = x % m; ll res = 1; while (y) {if (y & 1)res = res * x; res %= m; y = y >> 1; x = x * x; x %= m;} return res % m;}
//###########################################//
vector<ll int>prime(10000000, 1);
void sieve() {
    for (int i = 2; i <= 10000; i++) {
        if (prime[i]) {
            for (int j = i * i; j < 10000000; j += i) {
                prime[j] = 0;
            }
        }
    }
}
//-----------------------------------------//
#define test() int tt=1; if(test){cin>>tt;}  while(tt--)

//###########################################//
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
//###########################################//
void filereader() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif
}
//###########################################//

// int vis[1050][1050] = {0};
int dp[1050][1050];
int r, c;

// H
int solve(string s[], int i, int j)
{
    if (i >= r or j >= c)
    {
        return 0;
    }

    if (dp[i][j] != -1)
    {
        run
        return dp[i][j];
    }
    if (s[i][j] == '#')
    {
        run
        return dp[i][j] = 0;
    }
    run
    dp[i][j] = (solve(s, i + 1, j) + solve(s, i, j + 1)) % MOD;
    return dp[i][j];

}

int main() {

    debug = 0;
    test = 0;

    test() {

        // set<int>s;
        // vi v;

        // rep(i, 10)
        // {
        //     s.insert(i * 10);
        //     v.pb(i * 10);
        // }
        // cout << *(s.upper_bound(45)) << endl;
        // cout << *(s.upper_bound(50)) << endl;

        // cout << *(upper_bound(v.begin(), v.end(), 50) ) << endl;

        cin >> r >> c;

        string s[r];

        rep(i, r)
        {
            cin >> s[i];
        }

        rep(i, 1050)
        {
            rep(j, 1050)
            {
                dp[i][j] = -1;
            }
        }

        // vis[r - 1][c - 1] = 1;
        dp[r - 1][c - 1] = 1;
        cout << (solve(s, 0, 0) % MOD );

    }
}
/*
F
Maximum Circular Sum CodeChef Qn

Digit DP
*/

/*

 E sum of digits qn

        int n, k;
        cin >> n >> k;

        k++;

        ll int b = (n - (k * (k + 1)) / 2);

        ll int x = b / (9 * k);

        cout << "val=" << 9 * x*k << endl;
        cout << x << endl;
        cout << endl;
*/


Measured memory_bytes: 87744