#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define SZ(a) (int)(a).size()
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define iFOR(i, a, b) for(int i=(a); i>=(b); --i)
#define make_unique(a) sort(all((a))), (a).resize(unique(all((a)))-(a).begin())

using namespace std;

typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long UL; // ULLONG_MAX, %llu
typedef unsigned int UI; //UINT_MAX %u
typedef double DD;
typedef long double LD;
typedef pair<LL,LL> PLL;
typedef pair<DD,DD> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;

int mod;
void adding(int &a, int b){
    if((a+=b) >= mod) a -= mod;
}
int add(int a, int b){
    if((a+=b) >= mod) return a - mod;
    return a;
}
int mul(int a, int b){
    return a * 1ll * b % mod;
}
const int N = 101;
int dp[N][130000];
int sum[N][130000];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, K;
    cin >> n >> K >> mod;
    int Max = 129999;
    dp[0][0] = sum[0][0] = 1;
    FOR(i, 1, n){
        dp[i][0] = sum[i][0] = 1;
        FOR(j, 1, Max){
            sum[i-1][j] = dp[i-1][j];
            if(j >= i) adding(sum[i-1][j],sum[i-1][j-i]);
        }
        FOR(j, 1, Max){
            dp[i][j] = sum[i-1][j];
            if(j >= (K+1)*i) adding(dp[i][j], mod-sum[i-1][j-(K+1)*i]);
        }
    }
    FOR(x, 1, n){
        // try all mean
        int ans = K;
        FOR(i, 1, Max) adding(ans, mul( mul(dp[x-1][i], dp[n-x][i]), K+1));
        cout << ans << endl;
    }
	return 0;
}
/*
 *
 *
 *
 *
 *
 *
 *
 *
 *
 *
 */
//    .------------------------------------------------------------.
//    |                     K U S A Y A R O U                      |
//    |                                                            |
//    |        ---|---|---      ___   ____       _\_   ___         |
//    |          _______       |_|_|     /      |___| |  /         |
//    |         |_______|      |_|_|    \       |___| | /          |
//    |         |_______|        |   _____      |     |  \         |
//    |        _____|_____     __|__   | /      |  \  | __\        |
//    |             |            |     |        | / \ |            |
//    |             |          __|__  \|        |/    |            |
//    |                                                            |
//    |------------------------------------------------------------|
//    |                      .------------.                        |
//    |                      | KerakTelor |                        |
//    |                      |------------|                        |
//    |                      | 2020-07-21 |                        |
//    |                      '------------'                        |
//    '------------------------------------------------------------'

#include <bits/stdc++.h>
#define DEBUG(...)

// #pragma GCC optimize("O2,unroll-loops")
// #pragma GCC target("tune=native")

#define fi first
#define se second

using namespace std;

using ll = long long;
using ld = long double;

template<class T>
using vec = vector<T>;
template<class T>
using v2d = vector<vector<T>>;
template<class T>
using prq = priority_queue<T>;
template<class T>
using rpq = priority_queue<T, vector<T>, greater<T>>;

int main()
{
    const int MOD = 1e9 + 7;
    int y, x;
    scanf("%d %d", &y, &x);
    v2d<int> g(y, vec<int>(x));
    for(auto& i : g)
    {
        getchar();
        for(auto& j : i)
        {
            j = getchar() == '#';
        }
    }
    v2d<int> ps(y, vec<int>(x));
    vec<int> ysum(x), xsum(y), dsum(x + y);
    ps[0][0] = 1;
    xsum[0] = 1;
    ysum[0] = 1;
    dsum[x] = 1;
    for(int i = 0; i < y; ++i)
    {
        for(int j = 0; j < x; ++j)
        {
            if(!i && !j)
            {
                continue;
            }
            int d = i - j + x;
            if(!g[i][j])
            {
                ps[i][j] = (ps[i][j] + ysum[j]) % MOD;
                ps[i][j] = (ps[i][j] + xsum[i]) % MOD;
                ps[i][j] = (ps[i][j] + dsum[d]) % MOD;
                ysum[j] = (ysum[j] + ps[i][j]) % MOD;
                xsum[i] = (xsum[i] + ps[i][j]) % MOD;
                dsum[d] = (dsum[d] + ps[i][j]) % MOD;
            }
            else
            {
                ps[i][j] = 0;
                ysum[j] = 0;
                xsum[i] = 0;
                dsum[d] = 0;
            }
        }
    }
    printf("%d\n", ps[y - 1][x - 1]);
}

