#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,int> P;
typedef tuple<int,int,int> tii;
typedef vector<int> vec;
typedef vector<vec> mat;
#define rep(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define bit(n,k) (n>>k&1)

ll INFL = 1e18+5;
int INF = 1001001001;
const int M = 1e9+7;
int dx[4] = {-1,1,0,0};
int dy[4] = {0,0,1,-1};

int h,w;
string field[2005]; 
int main(){
    cin >> h >> w;
    rep(i,0,h) cin >> field[i];
    vector<vector<ll>> x(h+1,vector<ll>(w+1,0));
    vector<vector<ll>> y(h+1,vector<ll>(w+1,0));
    vector<vector<ll>> z(h+1,vector<ll>(w+1,0));
    vector<vector<ll>> dp(h+1,vector<ll>(w+1,0));
    dp[1][1] = 1;
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(field[i-1][j-1]=='#'){
                x[i][j] = 0;
                y[i][j] = 0;
                z[i][j] = 0;
                dp[i][j] = 0;
                continue;
            }
            x[i][j] = (x[i][j-1] + dp[i][j-1])%M;
            y[i][j] = (y[i-1][j] + dp[i-1][j])%M;
            z[i][j] = (z[i-1][j-1] + dp[i-1][j-1])%M;
            dp[i][j] += (x[i][j] + y[i][j] + z[i][j])%M;
        }
    }
    cout << dp[h][w]%M << endl;
}



#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
int mod = 1000000007;
int add(int x, int y) { return (x += y) >= mod ? x - mod : x; }
template<class... T> int add(int x, T... y) { return add(x, add(y...)); }
int mul(int x, int y) { return 1LL * x * y % mod; }
template<class... T> int mul(int x, T... y) { return mul(x, mul(y...)); }
int sub(int x, int y) { return add(x, mod - y); }
int modpow(int a, long long b) {
	int ret = 1; while (b > 0) {
		if (b & 1) ret = 1LL * ret * a % mod; a = 1LL * a * a % mod; b >>= 1;
	} return ret;
}
int modinv(int a) { return modpow(a, mod - 2); }
void chadd(int& x, int y) { x = add(x, y); }
void chsub(int& x, int y) { x = sub(x, y); }
void chmul(int& x, int y) { x = mul(x, y); }
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, K, M;
const int MA = 251010;
int dp[101][MA];
//---------------------------------------------------------------------------------------------------
deque<int> que[101];
int tot[101];
void _main() {
	cin >> N >> K >> mod;
	
	dp[0][0] = 1;
	rep(i, 0, 100) {
		rep(m, 0, i + 1) {
			que[m].clear();
			tot[m] = 0;
		}
		rep(sm, 0, MA) {
			if (que[sm % (i + 1)].size() == K + 1) {
				int tp = que[sm % (i + 1)].front(); que[sm % (i + 1)].pop_front();
				chsub(tot[sm % (i + 1)], tp);
			}
			que[sm % (i + 1)].push_back(dp[i][sm]);
			chadd(tot[sm % (i + 1)], dp[i][sm]);
			chadd(dp[i + 1][sm], tot[sm % (i + 1)]);
		}
	}

	rep(x, 1, N + 1) {
		int lft = x - 1, rht = N - x;
		int ans = 0;
		rep(sm, 0, MA) chadd(ans, mul(dp[lft][sm], dp[rht][sm], K + 1));
		chsub(ans, 1);
		printf("%d\n", ans);
	}
}





