#include <bits/stdc++.h>
using namespace std;
#define rep(i,x,n) for(int i=x;i<(int)n;++i)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define ceiling(a,b) ((a+b-1)/b)
#define out(a) cout<<a<<endl;
#define vout(v) rep(i,0,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vvout(vv) rep(j,0,vv.size()){vout(vv[j])}
#define mout(m) for(auto&e:m)cout<<e.first<<": "<<e.second<<endl;
#define _CHK_ 1
#define chk(a) if(_CHK_){cout<<#a<<": ";out(a)}
#define vchk(v) if(_CHK_){cout<<#v<<": ";vout(v)}
#define vvchk(vv) if(_CHK_){cout<<#vv<<": "<<endl;vvout(vv)}
#define mchk(m) if(_CHK_){cout<<#m<<": "<<endl;mout(m)}

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    // friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
    //     if (n == 0) return 1;
    //     auto t = modpow(a, n / 2);
    //     t = t * t;
    //     if (n & 1) t = t * a;
    //     return t;
    // }
};
const long long MOD = 1000000007;
using mint = Fp<MOD>;

mint modpow(const mint &a, int64_t n){
    if(n==0)return 1;
    mint t=modpow(a,n/2);
    t=t*t;
    if(n&1)t=t*a;
    return t;
}

int main(){
    int64_t H,W;
    cin>>H>>W;
    vector<vector<char>> S(H, vector<char>(W));
    for (int64_t i = 0; i < H; i++) {
        for (int64_t j = 0; j < W; j++) {
            cin>>S[i][j];
        }
    }
    // vvchk(S)

    vector<vector<int64_t>> dp(H, vector<int64_t>(W, 0));
    vector<vector<int64_t>> x(H, vector<int64_t>(W, 0));
    vector<vector<int64_t>> y(H, vector<int64_t>(W, 0));
    vector<vector<int64_t>> z(H, vector<int64_t>(W, 0));
    dp[0][0]=1;
    for (int64_t i = 0; i < H; i++) {
        for (int64_t j = 0; j < W; j++) {
            if(i==0&&j==0)continue;
            if(j-1>=0&&S[i][j-1]=='.'&&S[i][j]=='.') x[i][j]=x[i][j-1]+dp[i][j-1];
            if(i-1>=0&&S[i-1][j]=='.'&&S[i][j]=='.') y[i][j]=y[i-1][j]+dp[i-1][j];
            if(j-1>=0&&i-1>=0&&S[i-1][j-1]=='.'&&S[i][j]=='.') z[i][j]=z[i-1][j-1]+dp[i-1][j-1];
            dp[i][j]=x[i][j]+y[i][j]+z[i][j];
            dp[i][j]%=MOD;
        }
    }
    // vvchk(x)
    // vvchk(y)
    // vvchk(z)
    // vvchk(dp)
    out(dp[H-1][W-1])

    return 0;
}

#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
string i_t_s(int x){
	string t="";
	while(x){
		t+=x%10+'0';
		x/=10;
	}
	reverse(all(t));
	re t;
}
int s_t_i(string t){
	int x=0;
	rep(i,sz(t)){
		x=x*10+(t[i]-'0');
	}
	re x;
}
bool vis[8];
int n;
ll t[8][8];
ll k;
int ans;
void dfs(int x,int cnt,ll sum){
	if(cnt==n&&x==0&&sum==k){
		ans++;
		re;
	}
	if(vis[x])
	re;
	vis[x]=true;
	rep(i,n){
		if(sum+t[x][i]>k)
		continue;
		dfs(i,cnt+1,sum+t[x][i]);
	}
	vis[x]=false;
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n>>k;
	rep(i,n)
	rep(j,n)
	cin>>t[i][j];
	dfs(0,0,0);
	cout<<ans;
	re 0;
}
