/* be name khoda */

// #define stream_enable
// #define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_dav].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = ((a) + (b)) % p
#define Mul(a, b) a = (1LL * (a) * (b)) % p

stringstream sss;

// -----------------------------------------------------------------------

const ll maxm = 20;
const ll maxn = 1 << maxm;

typedef array<ll, maxm + 1> F;

ll m, n, p;
long long t;
ll ent[maxm + 1][maxm + 1];
ll dp[maxm + 1][maxn];
F A, B;

F merge(F &X, F &Y) {
    F Z;
    Z.fill(0);
    fori (i, m + 1) {
        fori (j, i + 1) {
            fori (k, m - i + 1) {
                Add(Z[i], 1LL * ent[j][i] * ent[k][m - i] % p * X[j + k] % p * Y[k + i - j]);
            }
        }
    }
    return Z;
}

F power(F &A, long long t) {
    F B;
    B.fill(0); B[0] = 1;
    while (t) {
        if (t & 1) B = merge(B, A);
        A = merge(A, A);
        t >>= 1;
    }
    return B;
}

void MAIN() {

    cin >> m >> t >> p;
    n = 1 << m;
    fori (i, n) cin >> dp[0][i];
    fori (i, m + 1) cin >> A[i];

    fill(ent[0], ent[0] + maxm + 1, 1);
    fori (i, maxm) fori (j, maxm) Add(ent[i + 1][j + 1], ent[i][j] + ent[i + 1][j]);

    B = power(A, t);

    fori (i, m) {
        forir (j, m) {
            fori (k, n) {
                Add(dp[j + 1][k], dp[j][k ^ (1 << i)]);
            }
        }
    }

    fori (i, n) {
        ll v = 0;
        fori (j, m + 1) Add(v, 1LL * dp[j][i] * B[j]);
        cout << v << '\n';
    }

}

// -----------------------------------------------------------------------

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(
2 3 1000000009
3 4 9 5
0 1 2

2 1 1000000009
80 74 94 88
0 1 2

3 50 1000000009
8 3 48 59 4 3 0 1
4 3 8 2
    )";
    MAIN();
    return 0;
}


/* be name khoda */

// #define stream_enable
// #define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_dav].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = ((a) + (b)) % MOD
#define Mul(a, b) a = (1LL * (a) * (b)) % MOD

stringstream sss;

// -----------------------------------------------------------------------

const ll maxm = 20;
const ll maxn = 1 << maxm;

typedef array<ll, maxm + 1> F;

ll m, n, p;
long long t;
ll ent[maxm + 1][maxm + 1];
ll dp[maxm + 1][maxn];
F A, B;

F merge(F &X, F &Y) {
    F Z;
    Z.fill(0);
    fori (i, m + 1) {
        fori (j, i + 1) {
            fori (k, m - i + 1) {
                Add(Z[i], 1LL * ent[j][i] * ent[k][m - i] % p * X[j + k] % p * Y[k + i - j]);
            }
        }
    }
    return Z;
}

F power(F &A, ll t) {
    F B;
    B.fill(0); B[0] = 1;
    while (t) {
        if (t & 1) B = merge(B, A);
        A = merge(A, A);
        t >>= 1;
    }
    return B;
}

void MAIN() {

    cin >> m >> t >> p;
    n = 1 << m;
    fori (i, n) cin >> dp[0][i];
    fori (i, m + 1) cin >> A[i];

    fill(ent[0], ent[0] + maxm + 1, 1);
    fori (i, maxm) fori (j, maxm) ent[i + 1][j + 1] = (ent[i][j] + ent[i + 1][j]) % p;

    B = power(A, t);

    fori (i, m) {
        forir (j, m) {
            fori (k, n) {
                Add(dp[j + 1][k], dp[j][k ^ (1 << i)]);
            }
        }
    }

    fori (i, n) {
        ll v = 0;
        fori (j, m + 1) Add(v, 1LL * dp[j][i] * B[j]);
        cout << v << '\n';
    }

}

// -----------------------------------------------------------------------

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(
3 50 1000000009
8 3 48 59 4 3 0 1
4 3 8 2
    )";
    MAIN();
    return 0;
}


/* be name khoda */

// #define stream_enable
// #define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cout << #x << " -> " << (x) << endl
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_dav].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = ((a) + (b)) % p
#define Mul(a, b) a = (1LL * (a) * (b)) % p

stringstream sss;

// -----------------------------------------------------------------------

const ll maxm = 20;
const ll maxn = 1 << maxm;

typedef array<ll, maxm + 1> F;

ll m, n, p;
long long t;
ll ent[maxm + 1][maxm + 1];
ll dp[maxm + 1][maxn];
F A, B;

F merge(F &X, F &Y) {
    F Z;
    Z.fill(0);
    fori (i, m + 1) {
        fori (j, i + 1) {
            fori (k, m - i + 1) {
                Add(Z[i], 1LL * ent[j][i] * ent[k][m - i] % p * X[j + k] % p * Y[k + i - j]);
            }
        }
    }
    return Z;
}

F power(F &A, ll t) {
    F B;
    B.fill(0); B[0] = 1;
    while (t) {
        if (t & 1) B = merge(B, A);
        A = merge(A, A);
        t >>= 1;
    }
    return B;
}

void MAIN() {

    cin >> m >> t >> p;
    n = 1 << m;
    fori (i, n) cin >> dp[0][i];
    fori (i, m + 1) cin >> A[i];

    fill(ent[0], ent[0] + maxm + 1, 1);
    fori (i, maxm) fori (j, maxm) Add(ent[i + 1][j + 1], ent[i][j] + ent[i + 1][j]);

    B = power(A, t);

    fori (i, m) {
        forir (j, m) {
            fori (k, n) {
                Add(dp[j + 1][k], dp[j][k ^ (1 << i)]);
            }
        }
    }

    fori (i, n) {
        ll v = 0;
        fori (j, m + 1) Add(v, 1LL * dp[j][i] * B[j]);
        cout << v << '\n';
    }

}

// -----------------------------------------------------------------------

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(
2 3 1000000009
3 4 9 5
0 1 2

2 1 1000000009
80 74 94 88
0 1 2

3 50 1000000009
8 3 48 59 4 3 0 1
4 3 8 2
    )";
    MAIN();
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define clr(x) memset(x,0,sizeof x)
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

const int N=(1<<20)+5;
ll f[N],g[N],b[25],n,mod,t;

ll fix(ll x){
	return x>=mod?x-mod:x;
}
ll power(ll x,ll p){
	ll res=1;
	for(;p;p>>=1,x=(__int128)x*x%mod)
		if(p&1) res=(__int128)res*x%mod;
	return res;
}

void fwt(ll *a,int n){
	for(int k=0,d=1;k<n;k++,d<<=1){
		for(int i=0;i<(1<<n);i+=d<<1){
			ll *l=a+i,*r=a+i+d;
			for(int j=0;j<d;j++,l++,r++){
				ll t=*r;
				*r=fix(*l+mod-t);
				*l=fix(*l+t);
			}
		}
	}
}

int main(){
	read(n),read(t),read(mod);
	mod<<=n;
	REP(i,1<<n) read(f[i]);
	rep(i,0,n) read(b[i]);
	REP(i,1<<n) g[i]=b[__builtin_popcount(i)];
	fwt(f,n),fwt(g,n);
	REP(i,1<<n){
		f[i]=(__int128)f[i]*power(g[i],t)%mod;
	}
	fwt(f,n);
	REP(i,1<<n){
		f[i]=((f[i]%mod+mod)%mod)>>n;
		printf("%lld\n",f[i]);
	}
	return 0;
}


#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define clr(x) memset(x,0,sizeof x)
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

const int N=(1<<20)+5;
ll f[N],g[N],b[25],n,mod,t;

ll fix(ll x){
	return x>=mod?x-mod:x;
}
ll power(ll x,ll p){
	int res=1;
	for(;p;p>>=1,x=(__int128)x*x%mod)
		if(p&1) res=(__int128)res*x%mod;
	return res;
}

void fwt(ll *a,int n){
	for(int k=0,d=1;k<n;k++,d<<=1){
		for(int i=0;i<(1<<n);i+=d<<1){
			ll *l=a+i,*r=a+i+d;
			for(int j=0;j<d;j++,l++,r++){
				ll t=*r;
				*r=fix(*l+mod-t);
				*l=fix(*l+t);
			}
		}
	}
}

int main(){
	read(n),read(t),read(mod);
	mod<<=n;
	REP(i,1<<n) read(f[i]);
	rep(i,0,n) read(b[i]);
	REP(i,1<<n) g[i]=b[__builtin_popcount(i)];
	fwt(f,n),fwt(g,n);
	REP(i,1<<n){
		f[i]=(__int128)f[i]*power(g[i],t)%mod;
	}
	fwt(f,n);
	REP(i,1<<n){
		f[i]>>=n;
		printf("%lld\n",f[i]);
	}
	return 0;
}


#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define clr(x) memset(x,0,sizeof x)
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}

const int N=(1<<20)+5;
ll f[N],g[N],b[25],n,mod,t;

ll fix(ll x){
	return x>=mod?x-mod:x;
}
ll power(ll x,ll p){
	ll res=1;
	for(;p;p>>=1,x=(__int128)x*x%mod)
		if(p&1) res=(__int128)res*x%mod;
	return res;
}

void fwt(ll *a,int n){
	for(int k=0,d=1;k<n;k++,d<<=1){
		for(int i=0;i<(1<<n);i+=d<<1){
			ll *l=a+i,*r=a+i+d;
			for(int j=0;j<d;j++,l++,r++){
				ll t=*r;
				*r=fix(*l+mod-t);
				*l=fix(*l+t);
			}
		}
	}
}

int main(){
	read(n),read(t),read(mod);
	mod<<=n;
	REP(i,1<<n) read(f[i]);
	rep(i,0,n) read(b[i]);
	REP(i,1<<n) g[i]=b[__builtin_popcount(i)];
	fwt(f,n),fwt(g,n);
	REP(i,1<<n){
		f[i]=(__int128)f[i]*power(g[i],t)%mod;
	}
	fwt(f,n);
	REP(i,1<<n){
		f[i]>>=n;
		printf("%lld\n",f[i]);
	}
	return 0;
}


#ifdef _MSC_VER
#define __builtin_popcount (int)__popcnt
#define __builtin_popcountll (int)__popcnt64
#define __builtin_clz (int)__lzcnt
#define $ system("pause")
#else
#define $
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define MAXN int((1 << 20) + 20)
#define lg 17
#define inf int(1e8)

#define rep(i, j, k) for (int i = j; i < k; i++)
#define for_all(x) x.begin(), x.end()
#define lid id << 1
#define rid id << 1 | 1
#define lch l, mid, lid
#define rch mid, r, rid
#define pb push_back
#define X first
#define Y second

struct MAT {
	ll n = 0, m = 0, arr[22][22];
	MAT(int n_ = 0, int m_ = 0) {
		memset(arr, 0, sizeof(arr));
		n = n_, m = m_;
	}
};

ll n, t, MOD, m;
inline void add(ll &l, const ll &r) { l = (l + r) % MOD; }
ll po(ll v, ll u) { return u ? (po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD) : 1; }
MAT iden(int v)
{
	MAT ans(v, v);
	for (int i = 0; i < v; i++)
		ans.arr[i][i] = 1;
	return ans;
}

MAT operator* (const MAT & l, const MAT & r)
{
	MAT ans(l.n, r.m);
	for (int i = 0; i < ans.n; i++)
		for (int j = 0; j < ans.m; j++)
			for (int k = 0; k < l.m; k++)
				ans.arr[i][j] = (ans.arr[i][j] + l.arr[i][k] * r.arr[k][j]) % MOD;
	return ans;
}

MAT operator^ (const MAT & v, ll u)
{
	return u ? ((((v*v) ^ (u >> 1))) * (u & 1 ? v : iden(v.n))) : iden(v.n);
}

ll a[MAXN], b[22], en[22][22], dp[MAXN][22];
inline void W(ll &l, ll r) {
	if ((l += r) > MOD) l -= MOD;
}
inline void solve() {
	rep(i , 0 , m)
		dp[i][0] = a[i] % MOD;
	rep(q, 1, n + 1) {
		for (int w = 0; w < m; w += (1 << q)) {
			int l = w, r = w + (1 << q), mid = w + (1 << (q - 1));
			int d = 1 << (q - 1);
			rep(i, l, mid) rep(j, 1, n + 1)
				W(dp[i][j], dp[i + d][j - 1]);
			rep(i, mid, r) for (int j = n; j; j--) {
				W(dp[i][j], dp[i - d][j - 1]);
				if (j > 1) W(dp[i][j], MOD - dp[i][j - 2]);
			}
		}
	}
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> t >> MOD;
	rep(i, 0, 22) {
		en[i][i] = en[0][i] = 1;
		rep(j, 1, i) add(en[j][i], en[j - 1][i - 1] + en[j][i - 1]);
	}
	m = 1 << n;
	rep(i, 0, m) cin >> a[i];
	rep(i, 0, n + 1) cin >> b[i];
	MAT pre(n + 1, n + 1);
	rep(i, 0, n + 1) rep(j, 0, i + 1) rep(k, 0, n - i + 1)
		add(pre.arr[i][j + k], ((b[i - j + k] * en[j][i]) % MOD) * en[k][n - i]);
	pre = pre ^ t;
	rep(i, 0, n + 1) b[i] = pre.arr[i][n];
	solve();
	rep(i, 0, m) {
		ll res = 0;
		rep(j, 0, n + 1)
			add(res, dp[m - i - 1][j] * b[j]);
		cout << res << '\n';
	}
	$;
	return 0;
}


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

static long long mod;

inline void FWT_xor(long long a[], int n, bool inv = false) {
    for (int mid = 1; mid < n; mid <<= 1)
	for (int r = mid << 1, j = 0; j < n; j += r)
	    for (int k = 0; k < mid; k++) {
		long long x = a[j + k], y = a[j + mid + k];
		a[j + k] = (x + y) % mod;
		a[j + mid + k] = (x - y + mod) % mod;
		if (inv) {
		    a[j + k] >>= 1;
		    a[j + mid + k] >>= 1;
		}
	    }
}

inline long long qpow(long long a, long long b) {
    long long ans = 1;
    for (; b; b >>= 1, a = a * a % mod) {
	if (b & 1)
	    ans = ans * a % mod;
    }
    return ans;
}

const int N = (1 << 20) + 5;

const int M = 30;

static int m, n;

static long long t, e0[N], b[M], coef[N];

int main(int argc, char *argv[]) {
    scanf("%d%lld%lld", &m, &t, &mod);
    mod *= (n = 1 << m);
    for (int i = 0; i < n; i++) {
	scanf("%lld", e0 + i);
    }
    for (int i = 0; i <= m; i++) {
	scanf("%lld", b + i);
    }

    for (int i = 0; i < n; i++) {
	coef[i]= b[__builtin_popcount(i)];
    }

    FWT_xor(e0, n);
    FWT_xor(coef, n);

    for (int i = 0; i < n; i++) {
	e0[i] *= qpow(coef[i], t);
	e0[i] %= mod;
    }

    FWT_xor(e0, n, true);

    mod /= n;
    for (int i = 0; i < n; i++) {
	printf("%lld\n", e0[i] % mod);
    }

    return 0;
}


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

static long long mod;

inline void FWT_xor(long long a[], int n, bool inv = false) {
    for (int mid = 1; mid < n; mid <<= 1)
	for (int r = mid << 1, j = 0; j < n; j += r)
	    for (int k = 0; k < mid; k++) {
		long long x = a[j + k], y = a[j + mid + k];
		a[j + k] = (x + y) % mod;
		a[j + mid + k] = (x - y + mod) % mod;
		if (inv) {
		    a[j + k] >>= 1;
		    a[j + mid + k] >>= 1;
		}
	    }
}

inline long long mult(long long a, long long b) {
//    long long ans = 0;
//    for (; b; b >>= 1, a = 2 * a % mod) {
//	if (b & 1)
//	    ans = (ans + a) % mod;
//    }
//    return ans;
    long long t = (a * b - (long long)((long double) a / mod * b + 1e-8) * mod);
    return t < 0 ? t + mod : t;
}

inline long long qpow(long long a, long long b) {
    long long ans = 1;
    for (; b; b >>= 1, a = mult(a, a) % mod) {
	if (b & 1)
	    ans = mult(ans, a) % mod;
    }
    return ans;
}

const int N = (1 << 20) + 5;

const int M = 30;

static int m, n;

static long long t, e0[N], b[M], coef[N];

int main(int argc, char *argv[]) {
    scanf("%d%lld%lld", &m, &t, &mod);
    mod *= (n = 1 << m);
    for (int i = 0; i < n; i++) {
	scanf("%lld", e0 + i);
	e0[i] %= mod;
    }
    for (int i = 0; i <= m; i++) {
	scanf("%lld", b + i);
	b[i] %= mod;
    }

    for (int i = 0; i < n; i++) {
	coef[i]= b[__builtin_popcount(i)];
    }

    FWT_xor(e0, n);
    FWT_xor(coef, n);

    for (int i = 0; i < n; i++) {
	e0[i] = mult(e0[i], qpow(coef[i], t));
    }

    FWT_xor(e0, n, true);

    mod /= n;
    for (int i = 0; i < n; i++) {
	printf("%lld\n", e0[i] % mod);
    }

    return 0;
}


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

static long long mod;

inline void FWT_xor(long long a[], int n, bool inv = false) {
    for (int mid = 1; mid < n; mid <<= 1)
	for (int r = mid << 1, j = 0; j < n; j += r)
	    for (int k = 0; k < mid; k++) {
		long long x = a[j + k], y = a[j + mid + k];
		a[j + k] = (x + y) % mod;
		a[j + mid + k] = (x - y + mod) % mod;
		if (inv) {
		    a[j + k] >>= 1;
		    a[j + mid + k] >>= 1;
		}
	    }
}

inline long long mult(long long a, long long b) {
    long long ans = 0;
    for (; b; b >>= 1, a = 2 * a % mod) {
	if (b & 1)
	    ans = (ans + a) % mod;
    }
    return ans;
}

inline long long qpow(long long a, long long b) {
    long long ans = 1;
    for (; b; b >>= 1, a = mult(a, a) % mod) {
	if (b & 1)
	    ans = mult(ans, a) % mod;
    }
    return ans;
}

const int N = (1 << 20) + 5;

const int M = 30;

static int m, n;

static long long t, e0[N], b[M], coef[N];

int main(int argc, char *argv[]) {
    scanf("%d%lld%lld", &m, &t, &mod);
    mod *= (n = 1 << m);
    for (int i = 0; i < n; i++) {
	scanf("%lld", e0 + i);
	e0[i] %= mod;
    }
    for (int i = 0; i <= m; i++) {
	scanf("%lld", b + i);
	b[i] %= mod;
    }

    for (int i = 0; i < n; i++) {
	coef[i]= b[__builtin_popcount(i)];
    }

    FWT_xor(e0, n);
    FWT_xor(coef, n);

    for (int i = 0; i < n; i++) {
	e0[i] = mult(e0[i], qpow(coef[i], t));
    }

    FWT_xor(e0, n, true);

    mod /= n;
    for (int i = 0; i < n; i++) {
	printf("%lld\n", e0[i] % mod);
    }

    return 0;
}


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

static long long mod;

inline void FWT_xor(long long a[], int n, bool inv = false) {
    for (int mid = 1; mid < n; mid <<= 1)
	for (int r = mid << 1, j = 0; j < n; j += r)
	    for (int k = 0; k < mid; k++) {
		long long x = a[j + k], y = a[j + mid + k];
		a[j + k] = (x + y) % mod;
		a[j + mid + k] = (x - y + mod) % mod;
		if (inv) {
		    a[j + k] >>= 1;
		    a[j + mid + k] >>= 1;
		}
	    }
}

inline long long qpow(long long a, long long b) {
    long long ans = 1;
    for (; b; b >>= 1, a = a * a % mod) {
	if (b & 1)
	    ans = ans * a % mod;
    }
    return ans;
}

const int N = 1.1e5;

const int M = 30;

static int m, n;

static long long t, e0[N], b[M], coef[N];

int main(int argc, char *argv[]) {
    scanf("%d%lld%lld", &m, &t, &mod);
    mod *= (n = 1 << m);
    for (int i = 0; i < n; i++) {
	scanf("%lld", e0 + i);
    }
    for (int i = 0; i <= m; i++) {
	scanf("%lld", b + i);
    }

    for (int i = 0; i < n; i++) {
	coef[i]= b[__builtin_popcount(i)];
    }

    FWT_xor(e0, n);
    FWT_xor(coef, n);

    for (int i = 0; i < n; i++) {
	e0[i] *= qpow(coef[i], t);
	e0[i] %= mod;
    }

    FWT_xor(e0, n, true);

    mod /= n;
    for (int i = 0; i < n; i++) {
	printf("%lld\n", e0[i] % mod);
    }

    return 0;
}


#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
#define rg register
#define int __int128
void read(int &x){
    char ch;bool ok;
    for(ok=0,ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')ok=1;
    for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok)x=-x;
}
const int maxn=4e6;
int m,mod,b[maxn],n,a[maxn],c[maxn],t;
int get_phi(int x){
    int now=x,n=x;
    for(rg int i=2;i*i<=n;i++)
	if(x%i==0){
	    now=now/i*(i-1);
	    while(x%i==0)x/=i;
	}
    if(x>1)now=now/x*(x-1);
    return now;
}
int mi(int a,long long b){
    int ans=1;
    while(b){
	if(b&1)ans=ans*a%mod;
	b/=2,a=a*a%mod;
    }
    return ans;
}
void fwt_xor(int *a,int op){
    for(rg int i=1;i<n;i<<=1)
	for(rg int j=0;j<n;j+=(i<<1))
	    for(rg int k=0;k<i;k++){
		int x=a[j+k],y=a[j+k+i];
		a[j+k]=(x+y)%mod,a[j+k+i]=(x-y+mod)%mod;
		if(!op)a[j+k]>>=1,a[j+k+i]>>=1;
	    }

}
int get(int x){
    int now=0,ans=0;
    while(x){
	if(x&(1<<now))ans++,x^=(1<<now);
	now++;
    }
    return ans;
}
void print(int x){
	if (!x) return ;
	if (x < 0) putchar('-'),x = -x;
	print(x / 10);
	putchar(x % 10 + '0');
}
signed main(){
    read(m),read(t),read(mod);n=1<<m;mod*=n;
    for(rg int i=0;i<n;i++)read(a[i]),a[i]%=mod;
    for(rg int i=0;i<=m;i++)read(b[i]),b[i]%=mod;
    for(rg int i=0;i<n;i++)c[i]=b[get(i)];
    fwt_xor(a,1),fwt_xor(c,1);
    for(rg int i=0;i<n;i++)c[i]=mi(c[i],t),a[i]=a[i]*c[i]%mod;
    fwt_xor(a,0);mod/=n;
    for(rg int i=0;i<n;i++)print(a[i]%mod),puts("");
}


#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
#define rg register
#define int long long
void read(int &x){
    char ch;bool ok;
    for(ok=0,ch=getchar();!isdigit(ch);ch=getchar())if(ch=='-')ok=1;
    for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());if(ok)x=-x;
}
const int maxn=2e6;
int m,mod,b[maxn],n,a[maxn],c[maxn],phi,inv_2;long long t;
inline int mul(int x,int y){
    long long tmp=(x*y-(long long)((long double)x/mod*y+1e-8)*mod);
    return tmp<0?tmp+mod:tmp;
}
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int del(int x,int y){return x-y<0?x-y+mod:x-y;}
int get_phi(int x){
    int now=x,n=x;
    for(rg int i=2;i*i<=n;i++)
	if(x%i==0){
	    now=now/i*(i-1);
	    while(x%i==0)x/=i;
	}
    if(x>1)now=now/x*(x-1);
    return now;
}
int mi(int a,long long b){
    int ans=1;
    while(b){
	if(b&1)ans=mul(ans,a);
	b/=2,a=mul(a,a);
    }
    return ans;
}
void fwt_xor(int *a,int op){
    for(rg int i=1;i<n;i<<=1)
	for(rg int j=0;j<n;j+=(i<<1))
	    for(rg int k=0;k<i;k++){
		int x=a[j+k],y=a[j+k+i];
		a[j+k]=(x+y)%mod,a[j+k+i]=(x-y+mod)%mod;
		if(!op)a[j+k]>>=1,a[j+k+i]>>=1;
	    }

}
signed main(){
    read(m),scanf("%lld",&t),read(mod);n=1<<m;mod*=n;
    for(rg int i=0;i<n;i++)read(a[i]),a[i]%=mod;
    for(rg int i=0;i<=m;i++)read(b[i]),b[i]%=mod;
    for(rg int i=0;i<n;i++)
	for(rg int j=1;j<=m+2;j++)
	    if(i&(1<<(j-1))){c[i]=c[i^(1<<(j-1))]+1;break;}
    for(rg int i=0;i<n;i++)c[i]=b[c[i]];
    fwt_xor(a,1),fwt_xor(c,1);
    for(rg int i=0;i<n;i++)c[i]=mi(c[i],t),a[i]=mul(a[i],c[i]);
    fwt_xor(a,0);mod/=n;
    for(rg int i=0;i<n;i++)printf("%lld\n",a[i]%mod);
}


#include <bits/stdc++.h>

using namespace std;
typedef long long INT;
typedef double DO;
typedef pair<int, int> pii;
typedef vector<int> VI;

template<class T>
void gn(T &x) {
    static char c;
    while (c=getchar(), c<'0' || c>'9');
    for (x=0; c>='0'; x=(x<<1)+(x<<3)+c-'0', c=getchar());
}

template<class T>
void print(T x) {
    static char c[22]={0, };
    int t=21;
    while (x) c[--t]=x%10+'0', x/=10;
    if (t==21) c[--t]='0';
    puts(c+t);
}

INT mod;

const int NN = 1<<20;

int b[22], bit[NN];
INT x[22], e[NN];

inline INT mul(const INT &x, const INT &y) {
    return ((x*y-(INT)(x/(long double)mod*y+1e-5)*mod)%mod+mod)%mod;
}

inline INT power(INT a, INT b, INT ans=1) {
    for (; b; b>>=1, a=mul(a, a)) if (b&1) ans=mul(ans, a);
    return ans;
}

void fwt(INT e[], int n) {
    for (int m=1, n1=2; n1<=n; m=n1, n1<<=1) {
        for (int i=0; i<n; i+=n1) for (int j=0; j<m; j++) {
            const INT x = e[i|j], y = e[i|j|m];
            e[i|j]=x+y;
            e[i|j|m]=x-y;
            if (e[i|j]>=mod) e[i|j]-=mod;
            if (e[i|j|m]<0) e[i|j|m]+=mod;
        }
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("in.in", "r", stdin);
    freopen("out.out", "w", stdout);
#endif

    int m, p;
    INT t;
    gn(m); gn(t); gn(p);
    int n=1<<m;
    mod=(INT)p*n;
    for (int i=0; i<n; i++) gn(e[i]), e[i]%=mod;
    for (int i=0; i<=m; i++) gn(b[i]);
    for (int i=0; i<n; i++) bit[i]=bit[i>>1]+(i&1);
    for (int i=0; i<=m; i++) {
        int r=(1<<i)-1;
        for (int j=0; j<n; j++) {
            x[i]=(x[i]+(1-2*(bit[r&j]&1))*b[bit[j]]);
        }
        x[i]=(x[i]%mod+mod)%mod;
        x[i]=power(x[i], t);
    }

    fwt(e, n);
    for (int i=0; i<n; i++) e[i]=mul(e[i], x[bit[i]]);
    fwt(e, n);

    for (int i=0; i<n; i++) print(e[i]/n);

    return 0;
}


#include <assert.h>
#include <stdio.h>
#include <vector>
using namespace std;
#define PB push_back
typedef long long int ll;
constexpr int kN = 1048576;
int kMod;
ll Pow(ll a, ll b, int &n) {
	ll ans = 1;
	while (b) {
		if (b & 1) {
			ans = ans * a;
			while (!((n | ans) & 1)) {
				n >>= 1;
				ans >>= 1;
			}
			ans %= kMod;
		}
		a = a * a % kMod;
		b >>= 1;
	}
	return ans;
}

void FWT(vector<ll> &a, bool inverse) {
	int n = int(a.size());
	auto fix = [](ll &x, ll &y) {
		x = (x + y) % kMod;
		y = (kMod + kMod + x - (y << 1)) % kMod;
	};
	for (int i = 2; i <= n; i <<= 1)
		for (int j = 0; j < n; j += i)
			for (int k = j; k < j + (i >> 1); k++)
				fix(a[k], a[k + (i >> 1)]);
	return;
}

int main() {
	int m, n, tmp, v[30], I = 1;
	ll t, inv;
	vector<ll> a, b;
	scanf("%d%lld%d", &m, &t, &kMod);
	n = 1 << m;
	a.resize(n);
	b.resize(n);
	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	for (int i = 0; i <= m; i++) scanf("%lld", &v[i]);
	for (int i = 0; i < n; i++) b[i] = v[__builtin_popcount(i)];
	FWT(b, false);
	FWT(a, false);
	if (kMod & 1) {
		inv = Pow(n, kMod - 2, I);
		for (int i = 0; i < n; i++) a[i] = a[i] * Pow(b[i], t, I) % kMod;
		for (int i = 0; i < n; i++) a[i] = a[i] * inv % kMod;
	}
	else {
		for (int i = 0; i < n; i++) {
			tmp = n;
			a[i] = a[i] * Pow(b[i], t, tmp);
			while (!((tmp | a[i]) & 1)) {
				tmp >>= 1;
				a[i] >>= 1;
			}
			a[i] %= kMod;
			assert(a[i] % tmp == 0);
			a[i] /= tmp;
		}
	}
	FWT(a, false);
	for (int i = 0; i < n; i++) printf("%lld\n", a[i]);
}


#include <stdio.h>
#include <vector>
using namespace std;
#define PB push_back
typedef long long int ll;
constexpr int kN = 1048576;
ll kMod;
ll Pow(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if (b & 1) ans = ans * a % kMod;
		a = a * a % kMod;
		b >>= 1;
	}
	return ans;
}

void FWT(vector<ll> &a, bool inverse) {
	int n = int(a.size());
	ll inv = Pow(n, (kMod - 2));
	auto fix = [](ll &x, ll &y) {
		x = (x + y) % kMod;
		y = (kMod + kMod + x - (y << 1)) % kMod;
	};
	for (int i = 2; i <= n; i <<= 1)
		for (int j = 0; j < n; j += i)
			for (int k = j; k < j + (i >> 1); k++)
				fix(a[k], a[k + (i >> 1)]);
	if (inverse) for (int i = 0; i < n; i++) a[i] = a[i] * inv % kMod;
	return;
}

int main() {
	int m, n, v[30];
	ll t;
	vector<ll> a, b;
	scanf("%d%lld%lld", &m, &t, &kMod);
	kMod <<= m;
	n = 1 << m;
	a.resize(n);
	b.resize(n);
	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	for (int i = 0; i <= m; i++) scanf("%lld", &v[i]);
	for (int i = 0; i < n; i++) b[i] = v[__builtin_popcount(i)];
	FWT(b, false);
	FWT(a, false);
	for (int i = 0; i < n; i++) a[i] = a[i] * Pow(b[i], t) % kMod;
	FWT(a, true);
	kMod >>= m;
	for (int i = 0; i < n; i++) a[i] %= kMod;
	for (int i = 0; i < n; i++) printf("%lld\n", a[i]);
}


#include <assert.h>
#include <stdio.h>
#include <vector>
using namespace std;
#define PB push_back
typedef long long int ll;
constexpr int kN = 1048576;
int kMod;
ll Pow(ll a, ll b, ll &n) {
	ll ans = 1;
	while (b) {
		if (b & 1) {
			ans = ans * a;
			while (n > 0 && (ans & 1)) {
				n--;
				ans >>= 1;
			}
			ans %= kMod;
		}
		a = a * a % kMod;
		b >>= 1;
	}
	return ans;
}

void FWT(vector<ll> &a, bool inverse) {
	int n = int(a.size());
	auto fix = [](ll &x, ll &y) {
		x = (x + y);
		y = x - (y << 1);
	};
	for (int i = 2; i <= n; i <<= 1)
		for (int j = 0; j < n; j += i)
			for (int k = j; k < j + (i >> 1); k++)
				fix(a[k], a[k + (i >> 1)]);
	return;
}

int main() {
	int m, n, tmp, v[30];
	ll t, inv, x, I = 0;
	vector<ll> a, b;
	scanf("%d%lld%d", &m, &t, &kMod);
	n = 1 << m;
	a.resize(n);
	b.resize(n);
	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	for (int i = 0; i <= m; i++) scanf("%lld", &v[i]);
	for (int i = 0; i < n; i++) b[i] = v[__builtin_popcount(i)];
	FWT(b, false);
	FWT(a, false);
	if (kMod & 1) {
		for (int i = 0; i < n; i++) a[i] %= kMod;
		for (int i = 0; i < n; i++) b[i] %= kMod;
		inv = Pow(n, kMod - 2, I);
		for (int i = 0; i < n; i++) a[i] = a[i] * Pow(b[i], t, I) % kMod;
		for (int i = 0; i < n; i++) a[i] = a[i] * inv % kMod;
	}
	else {
		for (int i = 0; i < n; i++) {
			x = m;
			while (x > 0 && (b[i] & 1)) {
				x -= t;
				b[i] >>= 1;
			}
			a[i] = a[i] * Pow(b[i] % kMod, t, x);
			if (x < 0) {
				a[i] %= kMod;
				a[i] *= Pow(2, -x, I);
				a[i] %= kMod;
			}
			else {
				assert(a[i] % (1 << x) == 0);
				a[i] >>= x;
				a[i] %= kMod;
			}
			if (a[i] < 0) a[i] += kMod;
		}
	}
	FWT(a, false);
	for (int i = 0; i < n; i++) a[i] %= kMod;
	for (int i = 0; i < n; i++) if (a[i] < 0) a[i] += kMod;
	for (int i = 0; i < n; i++) printf("%lld\n", a[i]);
}


#include <stdio.h>
#include <vector>
using namespace std;
#define PB push_back
typedef long long int ll;
constexpr int kN = 1048576;
ll kMod;
ll Pow(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if (b & 1) ans = ans * a % kMod;
		a = a * a % kMod;
		b >>= 1;
	}
	return ans;
}

void FWT(vector<ll> &a, bool inverse) {
	int n = int(a.size());
	auto fix = [](ll &x, ll &y) {
		x = (x + y) % kMod;
		y = (kMod + kMod + x - (y << 1)) % kMod;
	};
	for (int i = 2; i <= n; i <<= 1)
		for (int j = 0; j < n; j += i)
			for (int k = j; k < j + (i >> 1); k++)
				fix(a[k], a[k + (i >> 1)]);
	if (inverse) for (int i = 0; i < n; i++) a[i] /= n;
	return;
}

int main() {
	int m, n, v[30];
	ll t;
	vector<ll> a, b;
	scanf("%d%lld%lld", &m, &t, &kMod);
	kMod <<= m;
	n = 1 << m;
	a.resize(n);
	b.resize(n);
	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	for (int i = 0; i <= m; i++) scanf("%lld", &v[i]);
	for (int i = 0; i < n; i++) b[i] = v[__builtin_popcount(i)];
	FWT(b, false);
	FWT(a, false);
	for (int i = 0; i < n; i++) a[i] = a[i] * Pow(b[i], t) % kMod;
	FWT(a, true);
	kMod >>= m;
	for (int i = 0; i < n; i++) a[i] %= kMod;
	for (int i = 0; i < n; i++) printf("%lld\n", a[i]);
}


#include <stdio.h>
#include <vector>
using namespace std;
#define PB push_back
typedef long long int ll;
constexpr int kN = 1048576;
ll kMod;
inline ll msc(ll a,ll b)
{
	    ll v=(a*b-(ll)((long double)a/kMod*b+1e-8)*kMod);
			    return v<0?v+kMod:v;
}
ll Pow(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if (b & 1) ans = msc(ans, a) % kMod;
		a = msc(a, a) % kMod;
		b >>= 1;
	}
	return ans;
}

void FWT(vector<ll> &a, bool inverse) {
	int n = int(a.size());
	auto fix = [](ll &x, ll &y) {
		x = (x + y) % kMod;
		y = (kMod + kMod + x - (y << 1)) % kMod;
	};
	for (int i = 2; i <= n; i <<= 1)
		for (int j = 0; j < n; j += i)
			for (int k = j; k < j + (i >> 1); k++)
				fix(a[k], a[k + (i >> 1)]);
	if (inverse) for (int i = 0; i < n; i++) a[i] /= n;
	return;
}

int main() {
	int m, n, v[30];
	ll t;
	vector<ll> a, b;
	scanf("%d%lld%lld", &m, &t, &kMod);
	kMod <<= m;
	n = 1 << m;
	a.resize(n);
	b.resize(n);
	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	for (int i = 0; i <= m; i++) scanf("%lld", &v[i]);
	for (int i = 0; i < n; i++) b[i] = v[__builtin_popcount(i)];
	FWT(b, false);
	FWT(a, false);
	for (int i = 0; i < n; i++) a[i] = msc(a[i], Pow(b[i], t));
	FWT(a, true);
	kMod >>= m;
	for (int i = 0; i < n; i++) a[i] %= kMod;
	for (int i = 0; i < n; i++) printf("%lld\n", a[i]);
}


#include <assert.h>
#include <stdio.h>
#include <vector>
using namespace std;
#define PB push_back
typedef long long int ll;
constexpr int kN = 1048576;
int kMod;
ll Pow(ll a, ll b, int &n) {
	ll ans = 1;
	while (b) {
		if (b & 1) {
			ans = ans * a;
			while (!((n | ans) & 1)) {
				n >>= 1;
				ans >>= 1;
			}
			ans %= kMod;
		}
		a = a * a % kMod;
		b >>= 1;
	}
	return ans;
}

void FWT(vector<ll> &a, bool inverse) {
	int n = int(a.size());
	auto fix = [](ll &x, ll &y) {
		x = (x + y) % kMod;
		y = (kMod + kMod + x - (y << 1)) % kMod;
	};
	for (int i = 2; i <= n; i <<= 1)
		for (int j = 0; j < n; j += i)
			for (int k = j; k < j + (i >> 1); k++)
				fix(a[k], a[k + (i >> 1)]);
	return;
}

int main() {
	int m, n, tmp, v[30];
	ll t, inv;
	vector<ll> a, b;
	scanf("%d%lld%d", &m, &t, &kMod);
	n = 1 << m;
	a.resize(n);
	b.resize(n);
	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	for (int i = 0; i <= m; i++) scanf("%lld", &v[i]);
	for (int i = 0; i < n; i++) b[i] = v[__builtin_popcount(i)];
	FWT(b, false);
	FWT(a, false);
	if (kMod & 1) {
		inv = Pow(n, kMod - 2);
		for (int i = 0; i < n; i++) a[i] = a[i] * Pow(b[i], t, 1) % kMod;
		for (int i = 0; i < n; i++) a[i] = a[i] * inv % kMod;
	}
	else {
		for (int i = 0; i < n; i++) {
			tmp = n;
			a[i] = a[i] * Pow(b[i], t, tmp);
			while (!((tmp | a[i]) & 1)) {
				tmp >>= 1;
				a[i] >>= 1;
			}
			a[i] %= kMod;
			assert(a[i] % tmp == 0);
			a[i] /= tmp;
		}
	}
	FWT(a, false);
	for (int i = 0; i < n; i++) printf("%lld\n", a[i]);
}


#include <assert.h>
#include <stdio.h>
#include <vector>
using namespace std;
#define PB push_back
typedef long long int ll;
constexpr int kN = 1048576;
int kMod;
ll Pow(ll a, ll b, int &n) {
	ll ans = 1;
	while (b) {
		if (b & 1) {
			ans = ans * a;
			while (!((n | ans) & 1)) {
				n >>= 1;
				ans >>= 1;
			}
			ans %= kMod;
		}
		a = a * a % kMod;
		b >>= 1;
	}
	return ans;
}

void FWT(vector<ll> &a, bool inverse) {
	int n = int(a.size());
	auto fix = [](ll &x, ll &y) {
		x = (x + y) % kMod;
		y = (kMod + kMod + x - (y << 1)) % kMod;
	};
	for (int i = 2; i <= n; i <<= 1)
		for (int j = 0; j < n; j += i)
			for (int k = j; k < j + (i >> 1); k++)
				fix(a[k], a[k + (i >> 1)]);
	return;
}

int main() {
	int m, n, tmp, v[30];
	ll t;
	vector<ll> a, b;
	scanf("%d%lld%d", &m, &t, &kMod);
	n = 1 << m;
	a.resize(n);
	b.resize(n);
	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	for (int i = 0; i <= m; i++) scanf("%lld", &v[i]);
	for (int i = 0; i < n; i++) b[i] = v[__builtin_popcount(i)];
	FWT(b, false);
	FWT(a, false);
	for (int i = 0; i < n; i++) {
		tmp = n;
		a[i] = a[i] * Pow(b[i], t, tmp);
		while (!((tmp | a[i]) & 1)) {
			tmp >>= 1;
			a[i] >>= 1;
		}
		a[i] %= kMod;
		assert(a[i] % tmp == 0);
		a[i] /= tmp;
	}
	FWT(a, false);
	for (int i = 0; i < n; i++) printf("%lld\n", a[i]);
}


#include <assert.h>
#include <stdio.h>
#include <vector>
using namespace std;
#define PB push_back
typedef long long int ll;
constexpr int kN = 1048576;
int kMod;
ll Pow(ll a, ll b, ll &n) {
	ll ans = 1;
	while (b) {
		if (b & 1) {
			ans = ans * a;
			while (n > 0 && (ans & 1)) {
				n--;
				ans >>= 1;
			}
			ans %= kMod;
		}
		a = a * a % kMod;
		b >>= 1;
	}
	return ans;
}

void FWT(vector<ll> &a, bool inverse) {
	int n = int(a.size());
	auto fix = [](ll &x, ll &y) {
		x = (x + y);
		y = x - (y << 1);
	};
	for (int i = 2; i <= n; i <<= 1)
		for (int j = 0; j < n; j += i)
			for (int k = j; k < j + (i >> 1); k++)
				fix(a[k], a[k + (i >> 1)]);
	return;
}

int main() {
	int m, n, tmp, v[30];
	ll t, inv, x, I = 0;
	vector<ll> a, b;
	scanf("%d%lld%d", &m, &t, &kMod);
	n = 1 << m;
	a.resize(n);
	b.resize(n);
	for (int i = 0; i < n; i++) scanf("%lld", &a[i]);
	for (int i = 0; i <= m; i++) scanf("%lld", &v[i]);
	for (int i = 0; i < n; i++) b[i] = v[__builtin_popcount(i)];
	FWT(b, false);
	FWT(a, false);
	if (kMod & 1) {
		for (int i = 0; i < n; i++) a[i] %= kMod;
		for (int i = 0; i < n; i++) b[i] %= kMod;
		inv = Pow(n, kMod - 2, I);
		for (int i = 0; i < n; i++) a[i] = a[i] * Pow(b[i], t, I) % kMod;
		for (int i = 0; i < n; i++) a[i] = a[i] * inv % kMod;
	}
	else {
		for (int i = 0; i < n; i++) {
			x = m;
			while (x > 0 && (b[i] & 1)) {
				x -= t;
				b[i] >>= 1;
			}
			a[i] = a[i] * Pow(b[i], t, x);
			if (x < 0) {
				a[i] %= kMod;
				a[i] *= Pow(2, -x, I);
				a[i] %= kMod;
			}
			else {
				assert((a[i] & ((1 << x) - 1)) == 0);
				a[i] >>= x;
				a[i] %= kMod;
			}
		}
	}
	FWT(a, false);
	for (int i = 0; i < n; i++) printf("%lld\n", a[i]);
}


#include <bits/stdc++.h>

#define LL long long
#define pii pair<int,int>
using namespace std;
const int inf = 2147483647;
LL mod;

int _max(int x, int y) {return x > y ? x : y;}
int _min(int x, int y) {return x < y ? x : y;}
inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
    return x * f;
}
void put(int x) {
	if(x < 0) putchar('-'), x = -x;
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

int one[1 << 20], b[21];
LL f[1 << 20], s[1 << 20];

LL add(LL x, LL y) {
	x += y;
	return x >= mod ? x - mod : x;
}

LL dec(LL x, LL y) {
	x -= y;
	return x < 0 ? x + mod : x;
}

LL cheng(LL x, LL y) {
	LL ans = (x * y - (LL)((long double)x / mod * y + 1e-8) * mod);
    return ans < 0 ? ans + mod : ans;
}

LL pow_mod(LL a, LL k) {
	LL ans = 1;
	while(k) {
		if(k & 1) ans = cheng(ans, a);
		a = cheng(a, a), k /= 2;
	} return ans;
}

void FWT(LL y[], int len, int on) {
	for(int i = 1; i < len; i <<= 1) {
		for(int j = 0; j < len; j += i << 1) {
			for(int k = 0; k < i; k++) {
				LL u = y[j + k], v = y[j + k + i];
				y[j + k] = add(u, v), y[j + k + i] = dec(u, v);
			}
		}
	} if(on == -1) for(int i = 0; i < len; i++) y[i] /= len;
}

int main() {
	int m = read(); LL t = read(); mod = read();
	int len = 1 << m; mod *= len;
	for(int i = 0; i < len; i++) f[i] = read() % mod;
	for(int i = 0; i <= m; i++) b[i] = read() % mod;
	for(int i = 0; i < len; i++) one[i] = one[i >> 1] + (i & 1), s[i] = b[one[i]];
	FWT(f, len, 1), FWT(s, len, 1);
	for(int i = 0; i < len; i++) s[i] = pow_mod(s[i], t);
	for(int i = 0; i < len; i++) f[i] = cheng(f[i], s[i]);
	FWT(f, len, -1), mod /= len;
	for(int i = 0; i < len; i++) put(f[i] % mod), puts("");
	return 0;
}


#include <bits/stdc++.h>

#define LL long long
#define pii pair<int,int>
using namespace std;
const int inf = 2147483647;
LL mod;

int _max(int x, int y) {return x > y ? x : y;}
int _min(int x, int y) {return x < y ? x : y;}
inline LL read() {
    LL x = 0, f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
    return x * f;
}
void put(LL x) {
	if(x < 0) putchar('-'), x = -x;
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

int one[1 << 20], b[21];
LL f[1 << 20], s[1 << 20];

LL add(LL x, LL y) {
	x += y;
	return x >= mod ? x - mod : x;
}

LL dec(LL x, LL y) {
	x -= y;
	return x < 0 ? x + mod : x;
}

LL cheng(LL x, LL y) {
	LL ans = x * y - (LL)((long double)x / mod * y + 1e-8) * mod;
    return ans < 0 ? ans + mod : ans;
}

LL pow_mod(LL a, LL k) {
	LL ans = 1;
	while(k) {
		if(k & 1) ans = cheng(ans, a);
		a = cheng(a, a), k /= 2;
	} return ans;
}

void FWT(LL y[], int len, int on) {
	for(int i = 1; i < len; i <<= 1) {
		for(int j = 0; j < len; j += i << 1) {
			for(int k = 0; k < i; k++) {
				LL u = y[j + k], v = y[j + k + i];
				y[j + k] = add(u, v), y[j + k + i] = dec(u, v);
			}
		}
	} if(on == -1) for(int i = 0; i < len; i++) y[i] /= len;
}

int main() {
	int m = read(); LL t = read(); mod = read();
	int len = 1 << m; mod *= len;
	for(int i = 0; i < len; i++) f[i] = read() % mod;
	for(int i = 0; i <= m; i++) b[i] = read() % mod;
	for(int i = 0; i < len; i++) one[i] = one[i >> 1] + (i & 1), s[i] = b[one[i]];
	FWT(f, len, 1), FWT(s, len, 1);
	for(int i = 0; i < len; i++) f[i] = cheng(f[i], pow_mod(s[i], t));
	FWT(f, len, -1), mod /= len;
	for(int i = 0; i < len; i++) put(f[i] % mod), puts("");
	return 0;
}


#include <bits/stdc++.h>

#define LL long long
#define pii pair<int,int>
using namespace std;
const int inf = 2147483647;
LL mod;

int _max(int x, int y) {return x > y ? x : y;}
int _min(int x, int y) {return x < y ? x : y;}
inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
    return x * f;
}
void put(int x) {
	if(x < 0) putchar('-'), x = -x;
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

int one[1 << 20], b[21];
LL f[1 << 20], s[1 << 20];

LL add(LL x, LL y) {
	x += y;
	return x >= mod ? x - mod : x;
}

LL dec(LL x, LL y) {
	x -= y;
	return x < 0 ? x + mod : x;
}

LL cheng(LL x, LL y) {
	LL ans = (x * y - (LL)((long double)x / mod * y + 1e-8) * mod) % mod;
    return ans < 0 ? ans + mod : ans;
}

LL pow_mod(LL a, LL k) {
	LL ans = 1;
	while(k) {
		if(k & 1) ans = cheng(ans, a);
		a = cheng(a, a), k /= 2;
	} return ans;
}

void FWT(LL y[], int len, int on) {
	for(int i = 1; i < len; i <<= 1) {
		for(int j = 0; j < len; j += i << 1) {
			for(int k = 0; k < i; k++) {
				LL u = y[j + k], v = y[j + k + i];
				y[j + k] = add(u, v), y[j + k + i] = dec(u, v);
			}
		}
	} if(on == -1) for(int i = 0; i < len; i++) y[i] /= len;
}

int main() {
	int m = read(); LL t = read(); mod = read();
	int len = 1 << m; mod *= len;
	for(int i = 0; i < len; i++) f[i] = read() % mod;
	for(int i = 0; i <= m; i++) b[i] = read() % mod;
	for(int i = 0; i < len; i++) one[i] = one[i >> 1] + (i & 1), s[i] = b[one[i]];
	FWT(f, len, 1), FWT(s, len, 1);
	for(int i = 0; i < len; i++) f[i] = cheng(f[i], pow_mod(s[i], t));
	FWT(f, len, -1), mod /= len;
	for(int i = 0; i < len; i++) put(f[i] % mod), puts("");
	return 0;
}


#include <bits/stdc++.h>

#define LL long long
#define pii pair<int,int>
using namespace std;
const int inf = 2147483647;
LL mod;

int _max(int x, int y) {return x > y ? x : y;}
int _min(int x, int y) {return x < y ? x : y;}
inline int read() {
    int x = 0, f = 1; char ch = getchar();
    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
    while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
    return x * f;
}
void put(int x) {
	if(x < 0) putchar('-'), x = -x;
	if(x >= 10) put(x / 10);
	putchar(x % 10 + '0');
}

int one[1 << 20], b[21];
LL f[1 << 20], s[1 << 20];

LL add(LL x, LL y) {
	x += y;
	return x >= mod ? x - mod : x;
}

LL dec(LL x, LL y) {
	x -= y;
	return x < 0 ? x + mod : x;
}

LL cheng(LL x, LL y) {
	LL ans = (x * y - (LL)((long double)x / mod * y) * mod);
    return ans < 0 ? ans + mod : ans;
}

LL pow_mod(LL a, LL k) {
	LL ans = 1;
	while(k) {
		if(k & 1) ans = cheng(ans, a);
		a = cheng(a, a), k /= 2;
	} return ans;
}

void FWT(LL y[], int len, int on) {
	for(int i = 1; i < len; i <<= 1) {
		for(int j = 0; j < len; j += i << 1) {
			for(int k = 0; k < i; k++) {
				LL u = y[j + k], v = y[j + k + i];
				y[j + k] = add(u, v), y[j + k + i] = dec(u, v);
			}
		}
	} if(on == -1) for(int i = 0; i < len; i++) y[i] /= len;
}

int main() {
	int m = read(); LL t = read(); mod = read();
	int len = 1 << m; mod *= len;
	for(int i = 0; i < len; i++) f[i] = read() % mod;
	for(int i = 0; i <= m; i++) b[i] = read() % mod;
	for(int i = 0; i < len; i++) one[i] = one[i >> 1] + (i & 1), s[i] = b[one[i]];
	FWT(f, len, 1), FWT(s, len, 1);
	for(int i = 0; i < len; i++) s[i] = pow_mod(s[i], t);
	for(int i = 0; i < len; i++) f[i] = cheng(f[i], s[i]);
	FWT(f, len, -1), mod /= len;
	for(int i = 0; i < len; i++) put(f[i] % mod), puts("");
	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define maxn 25
#define int long long
using namespace std;

inline int rd(){
    int x=0,f=1;char c=' ';
    while(c<'0' || c>'9') f=c=='-'?-1:1,c=getchar();
    while(c<='9' && c>='0') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N=(1<<20)+5;
int m,mod,n,a[N],b[N],str[maxn],t,inv2;

inline int mul(int x,int y){
    long long tmp=(x*y-(long long)((long double)x/mod*y+1e-8)*mod);
    return tmp<0?tmp+mod:tmp;
}

inline int qpow(int x,int k){
    int ret=1;
    while(k){
        if(k&1) ret=mul(ret,x);
        x=mul(x,x); k>>=1;
    } return ret%mod;
}

inline int calc(int x){
    int ret=0;
    while(x){
        if(x&1) ++ret; x>>=1;
    } return ret;
}

inline void FWT(int *F,int type){
    for(int mid=1;mid<n;mid<<=1)
        for(int r=mid<<1,j=0;j<n;j+=r)
            for(int k=0;k<mid;k++){
                int x=F[j+k],y=F[j+mid+k];
                F[j+k]=(x+y)%mod,F[j+mid+k]=(x-y+mod)%mod;
                if(type==-1)
                    F[j+k]=F[j+k]>>1,F[j+mid+k]=F[j+mid+k]>>1;
            }
}

signed main(){
    m=rd(); t=rd(); mod=rd(); n=1<<m; mod*=n;
    for(int i=0;i<n;i++) a[i]=rd()%mod;
    for(int i=0;i<=m;i++) str[i]=rd()%mod;
    for(int i=0;i<n;i++) b[i]=str[calc(i)];
    FWT(a,1); FWT(b,1);
    for(int i=0;i<n;i++){
        b[i]=qpow(b[i],t);
        a[i]=mul(a[i],b[i]);
    }
    FWT(a,-1); mod/=n;
    for(int i=0;i<n;i++) printf("%lld\n",a[i]%mod);
    return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <cassert>

using namespace std;

#define REP(i, s, n) for (int i = (int)(s); i < (int)(n); ++i)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

#define NAIVE 0

const int DEBUG = 0;

ll add64(ll x, ll y, ll m) {
  ll res = x + y;
  if (res >= m) res -= m;
  return res;
}

ll mul64(ll x, ll y, ll m) {
  ll sum = 0;
  ll cur = x;
  while (y > 0) {
    if (y % 2) {
      sum = add64(sum, cur, m);
    }
    cur = add64(cur, cur, m);
    y /= 2;
  }
  return sum;
}

ll mod;

void add(ll &x, ll y) {
  x = (x + y) % mod;
}

const int M = 22;
ll comb[M][M];

void init(void) {
  comb[0][0] = 1;
  REP(i, 1, M) {
    REP(j, 0, M) {
      if (j > 0) {
	add(comb[i][j], comb[i - 1][j - 1]);
      }
      add(comb[i][j], comb[i - 1][j]);
    }
  }
}

ll mat[M][M][M];

VL mul(const VL &a, const VL &b) {
  int n = a.size();
  VL ret(n);
  REP(i, 0, n) {
    REP(j, 0, n) {
      REP(k, 0, n) {
	add(ret[k], (mat[i][j][k] * a[i] % mod) * b[j]);
      }
    }
  }
  return ret;
}

VL conv_fft_sub(const VL &a, const VL &b, ll mo) {
  if (a.size() <= 1) {
    return VL(1, mul64(a[0], b[0], mo));
  }
  int len = a.size();
  VL ap(len / 2), am(len / 2);
  VL bp(len / 2), bm(len / 2);
  REP(i, 0, len / 2) {
    ap[i] = add64(a[i], a[i + len / 2], mo);
    am[i] = add64(a[i], - a[i + len / 2] + mo, mo);
    bp[i] = add64(b[i], b[i + len / 2], mo);
    bm[i] = add64(b[i], - b[i + len / 2] + mo, mo);
  }
  VL x = conv_fft_sub(ap, bp, mo);
  VL y = conv_fft_sub(am, bm, mo);
  VL ret(len);
  REP(i, 0, len / 2) {
    ret[i] = (x[i] + y[i]) / 2;
    ret[i] %= mo;
    ret[i + len / 2] = add64(ret[i], -y[i] + mo, mo);
  }
  return ret;
}

VL conv_fft(const VL &a, const VL &b) {
  return conv_fft_sub(a, b, mod * (ll) a.size());
}

VL conv_naive(const VL &a, const VL &b) {
  VL ans(a.size());
  REP(i, 0, a.size()) {
    REP(j, 0, a.size()) {
      add(ans[i ^ j], a[i] * b[j]);
    }
  }
  return ans;
}

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int m;
  ll t;
  cin >> m >> t >> mod;
  ll oldt = t;
  init();
  VL e0(1 << m);
  REP(i, 0, 1 << m) cin >> e0[i];
  VL b(m + 1);
  REP(i, 0, m + 1) cin >> b[i];
  VL vec(m + 1);
  REP(i, 0, m + 1) vec[i] = b[i];
  // mat
  REP(i, 0, m + 1) {
    REP(j, 0, m + 1) {
      REP(x, 0, min(i, j) + 1) {
	int y = i + j - 2 * x;
	if (y > m) continue;
	ll tmp = comb[y][i - x];
	tmp = tmp * comb[m - y][x] % mod;
	mat[i][j][y] = tmp;
      }
    }
  }
  if (DEBUG) {
    REP(i, 0, m + 1) {
      REP(j, 0, m + 1) {
	cerr << "|" << i << ">|" << j <<">=";
	REP(x, 0, m + 1) {
	  cerr << " + " << mat[i][j][x] << "|" << x << ">";
	}
	cerr << endl;
      }
    }
  }
  VL cur(vec), prod(m + 1);
  prod[0] = 1;
  while (t > 0) {
    if (t % 2 == 1) {
      prod = mul(prod, cur);
    }
    cur = mul(cur, cur);
    t /= 2;
  }
  if (DEBUG) {
    cerr << "init^" << oldt << "=" << endl;
    REP(i, 0, m + 1) {
      cerr << " + " << prod[i] << "|" << i << ">";
    }
    cerr << endl;
  }
  // convolution
  VL coef(1 << m);
  REP(i, 0, 1 << m) {
    coef[i] = prod[__builtin_popcount(i)];
  }
  VL ans = conv_fft(e0, coef);
#if NAIVE
  VL ans_naive = conv_naive(e0, coef);
#endif
  if (DEBUG) {
    cerr << "ans:";
    REP(i, 0, 1 << m) {
      cerr << " " << ans[i];
    }
    cerr << endl;
#if NAIVE
    cerr << "naive:";
    REP(i, 0, 1 << m) {
      cerr << " " << ans_naive[i];
    }
    cerr << endl;
#endif
  }
  REP(i, 0, 1 << m) cout << ans[i] % mod << endl;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <cassert>

using namespace std;

#define REP(i, s, n) for (int i = (int)(s); i < (int)(n); ++i)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

#define NAIVE 0

const int DEBUG = 0;

ll add64(ll x, ll y, ll m) {
  ll res = x + y;
  if (res >= m) res -= m;
  return res;
}

ll mul64(ll x, ll y, ll m) {
  ll sum = 0;
  ll cur = x;
  while (y > 0) {
    if (y % 2) {
      sum = add64(sum, cur, m);
    }
    cur = add64(cur, cur, m);
    y /= 2;
  }
  return sum;
}

ll mod;

void add(ll &x, ll y) {
  x = (x + y) % mod;
}

const int M = 22;
ll comb[M][M];

void init(void) {
  comb[0][0] = 1;
  REP(i, 1, M) {
    REP(j, 0, M) {
      if (j > 0) {
	add(comb[i][j], comb[i - 1][j - 1]);
      }
      add(comb[i][j], comb[i - 1][j]);
    }
  }
}

ll mat[M][M][M];

VL mul(const VL &a, const VL &b) {
  int n = a.size();
  VL ret(n);
  REP(i, 0, n) {
    REP(j, 0, n) {
      REP(k, 0, n) {
	add(ret[k], (mat[i][j][k] * a[i] % mod) * b[j]);
      }
    }
  }
  return ret;
}

VL conv_fft_sub(const VL &a, const VL &b, ll mo) {
  if (a.size() <= 1) {
    return VL(1, mul64(a[0], b[0], mo));
  }
  int len = a.size();
  VL ap(len / 2), am(len / 2);
  VL bp(len / 2), bm(len / 2);
  REP(i, 0, len / 2) {
    ap[i] = add64(a[i], a[i + len / 2], mo);
    am[i] = add64(a[i], - a[i + len / 2] + mo, mo);
    bp[i] = add64(b[i], b[i + len / 2], mo);
    bm[i] = add64(b[i], - b[i + len / 2] + mo, mo);
  }
  VL x = conv_fft_sub(ap, bp, mo);
  VL y = conv_fft_sub(am, bm, mo);
  VL ret(len);
  REP(i, 0, len / 2) {
    ret[i] = (x[i] + y[i]) / 2;
    ret[i] %= mo;
    ret[i + len / 2] = add64(ret[i], -y[i] + mo, mo);
  }
  REP(i, 0, len) {
    assert (ret[i] <= mo);
  }
  return ret;
}

VL conv_fft(const VL &a, const VL &b) {
  return conv_fft_sub(a, b, mod * (ll) a.size());
}

VL conv_naive(const VL &a, const VL &b) {
  VL ans(a.size());
  REP(i, 0, a.size()) {
    REP(j, 0, a.size()) {
      add(ans[i ^ j], a[i] * b[j]);
    }
  }
  return ans;
}

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int m;
  ll t;
  cin >> m >> t >> mod;
  ll oldt = t;
  init();
  VL e0(1 << m);
  REP(i, 0, 1 << m) {
    cin >> e0[i];
    e0[i] %= mod;
  }
  VL b(m + 1);
  REP(i, 0, m + 1) cin >> b[i];
  VL vec(m + 1);
  REP(i, 0, m + 1) vec[i] = b[i] % mod;
  // mat
  REP(i, 0, m + 1) {
    REP(j, 0, m + 1) {
      REP(x, 0, min(i, j) + 1) {
	int y = i + j - 2 * x;
	if (y > m) continue;
	ll tmp = comb[y][i - x];
	tmp = tmp * comb[m - y][x] % mod;
	mat[i][j][y] = tmp;
      }
    }
  }
  if (DEBUG) {
    REP(i, 0, m + 1) {
      REP(j, 0, m + 1) {
	cerr << "|" << i << ">|" << j <<">=";
	REP(x, 0, m + 1) {
	  cerr << " + " << mat[i][j][x] << "|" << x << ">";
	}
	cerr << endl;
      }
    }
  }
  VL cur(vec), prod(m + 1);
  prod[0] = 1;
  while (t > 0) {
    if (t % 2 == 1) {
      prod = mul(prod, cur);
    }
    cur = mul(cur, cur);
    t /= 2;
  }
  if (DEBUG) {
    cerr << "init^" << oldt << "=" << endl;
    REP(i, 0, m + 1) {
      cerr << " + " << prod[i] << "|" << i << ">";
    }
    cerr << endl;
  }
  // convolution
  VL coef(1 << m);
  REP(i, 0, 1 << m) {
    coef[i] = prod[__builtin_popcount(i)];
  }
  VL ans = conv_fft(e0, coef);
#if NAIVE
  VL ans_naive = conv_naive(e0, coef);
#endif
  if (DEBUG) {
    cerr << "ans:";
    REP(i, 0, 1 << m) {
      cerr << " " << ans[i];
    }
    cerr << endl;
#if NAIVE
    cerr << "naive:";
    REP(i, 0, 1 << m) {
      cerr << " " << ans_naive[i];
    }
    cerr << endl;
#endif
  }
  REP(i, 0, 1 << m) cout << ans[i] % mod << endl;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

#define REP(i, s, n) for (int i = (int)(s); i < (int)(n); ++i)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

const int DEBUG = 0;

ll mod;

void add(ll &x, ll y) {
  x = (x + y) % mod;
}

const int M = 22;
ll comb[M][M];

void init(void) {
  comb[0][0] = 1;
  REP(i, 1, M) {
    REP(j, 0, M) {
      if (j > 0) {
	add(comb[i][j], comb[i - 1][j - 1]);
      }
      add(comb[i][j], comb[i - 1][j]);
    }
  }
}

ll mat[M][M][M];

VL mul(const VL &a, const VL &b) {
  int n = a.size();
  VL ret(n);
  REP(i, 0, n) {
    REP(j, 0, n) {
      REP(k, 0, n) {
	add(ret[k], (mat[i][j][k] * a[i] % mod) * b[j]);
      }
    }
  }
  return ret;
}

VL conv_fft_sub(const VL &a, const VL &b) {
  if (a.size() <= 1) {
    return VL(1, a[0] * b[0] % mod);
  }
  int len = a.size();
  VL ap(len / 2), am(len / 2);
  VL c0(len / 2), c1(len / 2);
  REP(i, 0, len / 2) {
    ap[i] = (a[i] + a[i + len / 2]) % mod;
    am[i] = (a[i] - a[i + len / 2] + mod) % mod;
  }
  ll parity = (b[0] + b[len / 2]) % 2;
  REP(i, 0, len / 2) {
    if (mod % 2 == 0 && (b[i] + b[i + len / 2]) % 2 != parity) {
      assert (0);
    }
    c0[i] = b[i] + b[i + len / 2] + parity;
    if (mod % 2 == 0) {
      c0[i] /= 2;
    } else {
      c0[i] = c0[i] * ((mod + 1) / 2) % mod;
    }
    c1[i] = (b[i] - c0[i] + mod) % mod;
  }
  VL x = conv_fft_sub(ap, c0);
  VL y = conv_fft_sub(am, c1);
  VL ret(len);
  ll a0sum = 0, a1sum = 0;
  REP(i, 0, len / 2) {
    a0sum += a[i];
    a1sum += a[i + len / 2];
  }
  a0sum %= mod;
  a1sum %= mod;
  REP(i, 0, len / 2) {
    ret[i] = x[i] + y[i] - a1sum * parity + mod;
    ret[i] %= mod;
    ret[i + len / 2] = x[i] - y[i] - a0sum * parity + 2 * mod;
    ret[i + len / 2] %= mod;
  }
  return ret;
}

VL conv_fft(const VL &a, const VL &b) {
  return conv_fft_sub(a, b);
}

VL conv_naive(const VL &a, const VL &b) {
  VL ans(a.size());
  REP(i, 0, a.size()) {
    REP(j, 0, a.size()) {
      add(ans[i ^ j], a[i] * b[j]);
    }
  }
  return ans;
}

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int m;
  ll t;
  cin >> m >> t >> mod;
  ll oldt = t;
  init();
  VL e0(1 << m);
  REP(i, 0, 1 << m) cin >> e0[i];
  VL b(m + 1);
  REP(i, 0, m + 1) cin >> b[i];
  VL vec(m + 1);
  REP(i, 0, m + 1) vec[i] = b[i];
  // mat
  REP(i, 0, m + 1) {
    REP(j, 0, m + 1) {
      REP(x, 0, min(i, j) + 1) {
	int y = i + j - 2 * x;
	if (y > m) continue;
	ll tmp = comb[y][i - x];
	tmp = tmp * comb[m - y][x] % mod;
	mat[i][j][y] = tmp;
      }
    }
  }
  if (DEBUG) {
    REP(i, 0, m + 1) {
      REP(j, 0, m + 1) {
	cerr << "|" << i << ">|" << j <<">=";
	REP(x, 0, m + 1) {
	  cerr << " + " << mat[i][j][x] << "|" << x << ">";
	}
	cerr << endl;
      }
    }
  }
  VL cur(vec), prod(m + 1);
  prod[0] = 1;
  while (t > 0) {
    if (t % 2 == 1) {
      prod = mul(prod, cur);
    }
    cur = mul(cur, cur);
    t /= 2;
  }
  if (DEBUG) {
    cerr << "init^" << oldt << "=" << endl;
    REP(i, 0, m + 1) {
      cerr << " + " << prod[i] << "|" << i << ">";
    }
    cerr << endl;
  }
  // convolution
  VL coef(1 << m);
  REP(i, 0, 1 << m) {
    coef[i] = prod[__builtin_popcount(i)];
  }
  VL ans = conv_fft(e0, coef);
  // VL ans_naive = conv_naive(e0, coef);
  if (DEBUG) {
    cerr << "ans:";
    REP(i, 0, 1 << m) {
      cerr << " " << ans[i];
    }
    cerr << endl;
  }
  REP(i, 0, 1 << m) cout << ans[i] << endl;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <cassert>

using namespace std;

#define REP(i, s, n) for (int i = (int)(s); i < (int)(n); ++i)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

#define NAIVE 0

const int DEBUG = 0;

ll add64(ll x, ll y, ll m) {
  ll res = x + y;
  if (res >= m) res -= m;
  return res;
}

ll mul64(ll x, ll y, ll m) {
  ll sum = 0;
  ll cur = x;
  while (y > 0) {
    if (y % 2) {
      sum = add64(sum, cur, m);
    }
    cur = add64(cur, cur, m);
    y /= 2;
  }
  return sum;
}

ll mod;

void add(ll &x, ll y) {
  x = (x + y) % mod;
}

const int M = 22;
ll comb[M][M];

void init(void) {
  comb[0][0] = 1;
  REP(i, 1, M) {
    REP(j, 0, M) {
      if (j > 0) {
	add(comb[i][j], comb[i - 1][j - 1]);
      }
      add(comb[i][j], comb[i - 1][j]);
    }
  }
}

ll mat[M][M][M];

VL mul(const VL &a, const VL &b) {
  int n = a.size();
  VL ret(n);
  REP(i, 0, n) {
    REP(j, 0, n) {
      REP(k, 0, n) {
	add(ret[k], (mat[i][j][k] * a[i] % mod) * b[j]);
      }
    }
  }
  return ret;
}

VL conv_fft_sub(const VL &a, const VL &b, ll mo) {
  if (a.size() <= 1) {
    return VL(1, mul64(a[0], b[0], mo));
  }
  int len = a.size();
  VL ap(len / 2), am(len / 2);
  VL bp(len / 2), bm(len / 2);
  REP(i, 0, len / 2) {
    ap[i] = add64(a[i], a[i + len / 2], mo);
    am[i] = add64(a[i], - a[i + len / 2] + mo, mo);
    bp[i] = add64(b[i], b[i + len / 2], mo);
    bm[i] = add64(b[i], - b[i + len / 2] + mo, mo);
  }
  VL x = conv_fft_sub(ap, bp, mo);
  VL y = conv_fft_sub(am, bm, mo);
  VL ret(len);
  REP(i, 0, len / 2) {
    ret[i] = (x[i] + y[i]) / 2;
    ret[i] %= mo;
    ret[i + len / 2] = add64(ret[i], -y[i] + mo, mo);
  }
  REP(i, 0, len) {
    assert (ret[i] <= mo);
  }
  return ret;
}

VL conv_fft(const VL &a, const VL &b) {
  return conv_fft_sub(a, b, mod * (ll) a.size());
}

VL conv_naive(const VL &a, const VL &b) {
  VL ans(a.size());
  REP(i, 0, a.size()) {
    REP(j, 0, a.size()) {
      add(ans[i ^ j], a[i] * b[j]);
    }
  }
  return ans;
}

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int m;
  ll t;
  cin >> m >> t >> mod;
  ll oldt = t;
  init();
  VL e0(1 << m);
  REP(i, 0, 1 << m) cin >> e0[i];
  VL b(m + 1);
  REP(i, 0, m + 1) cin >> b[i];
  VL vec(m + 1);
  REP(i, 0, m + 1) vec[i] = b[i];
  // mat
  REP(i, 0, m + 1) {
    REP(j, 0, m + 1) {
      REP(x, 0, min(i, j) + 1) {
	int y = i + j - 2 * x;
	if (y > m) continue;
	ll tmp = comb[y][i - x];
	tmp = tmp * comb[m - y][x] % mod;
	mat[i][j][y] = tmp;
      }
    }
  }
  if (DEBUG) {
    REP(i, 0, m + 1) {
      REP(j, 0, m + 1) {
	cerr << "|" << i << ">|" << j <<">=";
	REP(x, 0, m + 1) {
	  cerr << " + " << mat[i][j][x] << "|" << x << ">";
	}
	cerr << endl;
      }
    }
  }
  VL cur(vec), prod(m + 1);
  prod[0] = 1;
  while (t > 0) {
    if (t % 2 == 1) {
      prod = mul(prod, cur);
    }
    cur = mul(cur, cur);
    t /= 2;
  }
  if (DEBUG) {
    cerr << "init^" << oldt << "=" << endl;
    REP(i, 0, m + 1) {
      cerr << " + " << prod[i] << "|" << i << ">";
    }
    cerr << endl;
  }
  // convolution
  VL coef(1 << m);
  REP(i, 0, 1 << m) {
    coef[i] = prod[__builtin_popcount(i)];
  }
  VL ans = conv_fft(e0, coef);
#if NAIVE
  VL ans_naive = conv_naive(e0, coef);
#endif
  if (DEBUG) {
    cerr << "ans:";
    REP(i, 0, 1 << m) {
      cerr << " " << ans[i];
    }
    cerr << endl;
#if NAIVE
    cerr << "naive:";
    REP(i, 0, 1 << m) {
      cerr << " " << ans_naive[i];
    }
    cerr << endl;
#endif
  }
  REP(i, 0, 1 << m) cout << ans[i] % mod << endl;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>

using namespace std;

#define REP(i, s, n) for (int i = (int)(s); i < (int)(n); ++i)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

ll mod;

void add(ll &x, ll y) {
  x = (x + y) % mod;
}

const int M = 22;
ll comb[M][M];

void init(void) {
  comb[0][0] = 1;
  REP(i, 1, M) {
    REP(j, 0, M) {
      if (j > 0) {
	add(comb[i][j], comb[i - 1][j - 1]);
      }
      add(comb[i][j], comb[i - 1][j]);
    }
  }
}

ll mat[M][M][M];

VL mul(const VL &a, const VL &b) {
  int n = a.size();
  VL ret(n);
  REP(i, 0, n) {
    REP(j, 0, n) {
      REP(k, 0, n) {
	add(ret[k], (mat[i][j][k] * a[i] % mod) * b[j]);
  }
}

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int m;
  ll t;
  cin >> m >> t >> mod;
  init();
  VL e0(1 << m);
  REP(i, 0, 1 << m) cin >> e0[i];
  VL b(m + 1);
  REP(i, 0, m + 1) cin >> b[i];
  VL vec(m + 1);
  REP(i, 0, m + 1) vec[i] = comb[m][i];
  // TODO mat
  VL cur(vec), prod(m + 1);
  prod[0] = 1;
  while (t > 0) {
    if (t % 2 == 1) {
      prod = mul(prod, cur);
    }
    cur = mul(cur, cur);
    t /= 2;
  }
  // TODO convolution
}


#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <cassert>

using namespace std;

#define REP(i, s, n) for (int i = (int)(s); i < (int)(n); ++i)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

const int DEBUG = 0;

ll mod;

void add(ll &x, ll y) {
  x = (x + y) % mod;
}

const int M = 22;
ll comb[M][M];

void init(void) {
  comb[0][0] = 1;
  REP(i, 1, M) {
    REP(j, 0, M) {
      if (j > 0) {
	add(comb[i][j], comb[i - 1][j - 1]);
      }
      add(comb[i][j], comb[i - 1][j]);
    }
  }
}

ll mat[M][M][M];

VL mul(const VL &a, const VL &b) {
  int n = a.size();
  VL ret(n);
  REP(i, 0, n) {
    REP(j, 0, n) {
      REP(k, 0, n) {
	add(ret[k], (mat[i][j][k] * a[i] % mod) * b[j]);
      }
    }
  }
  return ret;
}

VL conv_fft_sub(const VL &a, const VL &b) {
  if (a.size() <= 1) {
    return VL(1, a[0] * b[0] % mod);
  }
  int len = a.size();
  VL ap(len / 2), am(len / 2);
  VL c0(len / 2), c1(len / 2);
  REP(i, 0, len / 2) {
    ap[i] = (a[i] + a[i + len / 2]) % mod;
    am[i] = (a[i] - a[i + len / 2] + mod) % mod;
  }
  ll parity = (b[0] + b[len / 2]) % 2;
  REP(i, 0, len / 2) {
    if (mod % 2 == 0 && (b[i] + b[i + len / 2]) % 2 != parity) {
      assert (0);
    }
    c0[i] = b[i] + b[i + len / 2] + parity;
    if (mod % 2 == 0) {
      c0[i] /= 2;
    } else {
      c0[i] = c0[i] * ((mod + 1) / 2) % mod;
    }
    c1[i] = (b[i] - c0[i] + mod) % mod;
  }
  VL x = conv_fft_sub(ap, c0);
  VL y = conv_fft_sub(am, c1);
  VL ret(len);
  ll a0sum = 0, a1sum = 0;
  REP(i, 0, len / 2) {
    a0sum += a[i];
    a1sum += a[i + len / 2];
  }
  a0sum %= mod;
  a1sum %= mod;
  REP(i, 0, len / 2) {
    ret[i] = x[i] + y[i] - a1sum * parity + mod;
    ret[i] %= mod;
    ret[i + len / 2] = x[i] - y[i] - a0sum * parity + 2 * mod;
    ret[i + len / 2] %= mod;
  }
  return ret;
}

VL conv_fft(const VL &a, const VL &b) {
  return conv_fft_sub(a, b);
}

VL conv_naive(const VL &a, const VL &b) {
  VL ans(a.size());
  REP(i, 0, a.size()) {
    REP(j, 0, a.size()) {
      add(ans[i ^ j], a[i] * b[j]);
    }
  }
  return ans;
}

int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int m;
  ll t;
  cin >> m >> t >> mod;
  ll oldt = t;
  init();
  VL e0(1 << m);
  REP(i, 0, 1 << m) cin >> e0[i];
  VL b(m + 1);
  REP(i, 0, m + 1) cin >> b[i];
  VL vec(m + 1);
  REP(i, 0, m + 1) vec[i] = b[i];
  // mat
  REP(i, 0, m + 1) {
    REP(j, 0, m + 1) {
      REP(x, 0, min(i, j) + 1) {
	int y = i + j - 2 * x;
	if (y > m) continue;
	ll tmp = comb[y][i - x];
	tmp = tmp * comb[m - y][x] % mod;
	mat[i][j][y] = tmp;
      }
    }
  }
  if (DEBUG) {
    REP(i, 0, m + 1) {
      REP(j, 0, m + 1) {
	cerr << "|" << i << ">|" << j <<">=";
	REP(x, 0, m + 1) {
	  cerr << " + " << mat[i][j][x] << "|" << x << ">";
	}
	cerr << endl;
      }
    }
  }
  VL cur(vec), prod(m + 1);
  prod[0] = 1;
  while (t > 0) {
    if (t % 2 == 1) {
      prod = mul(prod, cur);
    }
    cur = mul(cur, cur);
    t /= 2;
  }
  if (DEBUG) {
    cerr << "init^" << oldt << "=" << endl;
    REP(i, 0, m + 1) {
      cerr << " + " << prod[i] << "|" << i << ">";
    }
    cerr << endl;
  }
  // convolution
  VL coef(1 << m);
  REP(i, 0, 1 << m) {
    coef[i] = prod[__builtin_popcount(i)];
  }
  VL ans = conv_fft(e0, coef);
  // VL ans_naive = conv_naive(e0, coef);
  if (DEBUG) {
    cerr << "ans:";
    REP(i, 0, 1 << m) {
      cerr << " " << ans[i];
    }
    cerr << endl;
  }
  REP(i, 0, 1 << m) cout << ans[i] << endl;
}


#include<iostream>
#include<cstdio>
using namespace std;
#define N 1048577
#define LL long long
int n,len,b[21],siz[N],om;LL K,mod,a[N],C[21][21],f[21];
inline LL M(LL x){return (x>=mod)?(x-mod):x;}
inline LL M1(LL x){return (x<0)?(x+mod):x;}
inline LL mul(LL x,LL y){return ((__int128)x*y)%mod;}
inline LL ksm(LL p,LL k){LL res=1;while(k){if(k&1)res=mul(res,p);k>>=1;p=mul(p,p);}return res;}
inline void FWT(LL *f,int len)
{
	LL x,y;
	for(int j=1;j<len;j<<=1)
	for(int i=0;i<len;i++)if(i&j){x=f[i^j];y=f[i];f[i^j]=M(x+y);f[i]=M1(x-y);}
}
int main(){
	for(int i=1;i<N;i++)siz[i]=siz[i>>1]+(i&1);
	scanf("%d%lld%lld",&n,&K,&mod);om=mod;len=1<<n;mod*=len;int i,j,k,x;LL res;
	for(int i=0;i<=20;i++){C[i][0]=1;for(int j=1;j<=i;j++)C[i][j]=M(C[i-1][j-1]+C[i-1][j]);}
	for(i=0;i<len;i++)scanf("%d",&x),a[i]=x%om;for(i=0;i<=n;i++)scanf("%d",&b[i]),b[i]%=om;
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=n;j++)
		{
			res=0;for(k=0;k<=j;k++)res=M(M1(res+((k&1)?(-1):1)*mul(C[i][k],C[n-i][j-k])));
			f[i]=M(f[i]+mul(b[j],res));
		}f[i]=ksm(f[i],K);
	}
	FWT(a,len);for(i=0;i<len;i++)a[i]=mul(a[i],f[siz[i]]);FWT(a,len);for(i=0;i<len;i++)printf("%lld\n",a[i]>>(1ll*n));return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
#define N 1048577
#define LL long long
int n,len,b[21],siz[N];LL K,mod,a[N],C[21][21],f[21];
inline LL M(LL x){return (x>=mod)?(x-mod):x;}
inline LL M1(LL x){return (x<0)?(x+mod):x;}
inline LL mul(LL x,LL y){return ((__int128)x*y)%mod;}
inline LL ksm(LL p,LL k){LL res=1;while(k){if(k&1)res=mul(res,p);k>>=1;p=mul(p,p);}return res;}
inline void FWT(LL *f,int len)
{
	LL x,y;
	for(int j=1;j<len;j<<=1)
	for(int i=0;i<len;i++)if(i&j){x=f[i^j];y=f[i];f[i^j]=M(x+y);f[i]=M1(x-y);}
}
int main(){
	for(int i=1;i<N;i++)siz[i]=siz[i>>1]+(i&1);
	scanf("%d%lld%lld",&n,&K,&mod);len=1<<n;mod*=len;int i,j,k,x;LL res;
	for(int i=0;i<=20;i++){C[i][0]=1;for(int j=1;j<=i;j++)C[i][j]=M(C[i-1][j-1]+C[i-1][j]);}
	for(i=0;i<len;i++)scanf("%d",&x),a[i]=x;for(i=0;i<=n;i++)scanf("%d",&b[i]);
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=n;j++)
		{
			res=0;for(k=0;k<=j;k++)res=M(M1(res+((k&1)?(-1):1)*mul(C[i][k],C[n-i][j-k])));
			f[i]=M(f[i]+mul(b[j],res));
		}f[i]=ksm(f[i],K);
	}
	FWT(a,len);for(i=0;i<len;i++)a[i]=mul(a[i],f[siz[i]]);FWT(a,len);for(i=0;i<len;i++)printf("%lld\n",(a[i]>>(1ll*n))%mod);return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
#define N 1048577
#define LL long long
int n,len,b[21],siz[N];LL K,mod,a[N],C[21][21],f[21];
inline LL M(LL x){return (x>=mod)?(x-mod):x;}
inline LL M1(LL x){return (x<0)?(x+mod):x;}
inline LL mul(LL x,LL y){return ((__int128)x*y)%mod;}
inline LL ksm(LL p,LL k){LL res=1;while(k){if(k&1)res=mul(res,p);k>>=1;p=mul(p,p);}return res;}
inline void FWT(LL *f,int len)
{
	LL x,y;
	for(int j=1;j<len;j<<=1)
	for(int i=0;i<len;i++)if(i&j){x=f[i^j];y=f[i];f[i^j]=M(x+y);f[i]=M1(x-y);}
}
int main(){
	for(int i=1;i<N;i++)siz[i]=siz[i>>1]+(i&1);
	scanf("%d%lld%lld",&n,&K,&mod);len=1<<n;mod*=len;int i,j,k,x;LL res;
	for(int i=0;i<=20;i++){C[i][0]=1;for(int j=1;j<=i;j++)C[i][j]=M(C[i-1][j-1]+C[i-1][j]);}
	for(i=0;i<len;i++)scanf("%d",&x),a[i]=x;for(i=0;i<=n;i++)scanf("%d",&b[i]);
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=n;j++)
		{
			res=0;for(k=0;k<=j;k++)res=M(M1(res+((k&1)?(-1):1)*mul(C[i][k],C[n-i][j-k])));
			f[i]=M(f[i]+mul(b[j],res));
		}f[i]=ksm(f[i],K);
	}
	FWT(a,len);for(i=0;i<len;i++)a[i]=mul(a[i],f[siz[i]]);FWT(a,len);for(i=0;i<len;i++)printf("%lld\n",a[i]>>n);return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
#define N 1048577
#define LL long long
int n,len,b[21],siz[N],om;LL K,mod,a[N],C[21][21],f[21];
inline LL M(LL x){return (x>=mod)?(x-mod):x;}
inline LL M1(LL x){return (x<0)?(x+mod):x;}
inline LL mul(LL x,LL y){return ((__int128)x*y)%mod;}
inline LL ksm(LL p,LL k){LL res=1;while(k){if(k&1)res=mul(res,p);k>>=1;p=mul(p,p);}return res;}
inline void FWT(LL *f,int len)
{
	LL x,y;
	for(int j=1;j<len;j<<=1)
	for(int i=0;i<len;i++)if(i&j){x=f[i^j];y=f[i];f[i^j]=M(x+y);f[i]=M1(x-y);}
}
int main(){
	for(int i=1;i<N;i++)siz[i]=siz[i>>1]+(i&1);
	scanf("%d%lld%lld",&n,&K,&mod);om=mod;len=1<<n;mod*=len;int i,j,k,x;LL res;
	for(int i=0;i<=20;i++){C[i][0]=1;for(int j=1;j<=i;j++)C[i][j]=M(C[i-1][j-1]+C[i-1][j]);}
	for(i=0;i<len;i++)scanf("%d",&x),a[i]=x;for(i=0;i<=n;i++)scanf("%d",&b[i]);
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=n;j++)
		{
			res=0;for(k=0;k<=j;k++)res=M(M1(res+((k&1)?(-1):1)*mul(C[i][k],C[n-i][j-k])));
			f[i]=M(f[i]+mul(b[j],res));
		}f[i]=ksm(f[i],K);
	}
	FWT(a,len);for(i=0;i<len;i++)a[i]=mul(a[i],f[siz[i]]);FWT(a,len);for(i=0;i<len;i++)printf("%lld\n",(a[i]>>(1ll*n))%om);return 0;
}


#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<vector<ll> >mat;
ll mod;
mat e;
void makee(int n)
{
	e.clear();
	e.resize(n);
	for (int i = 0; i<n; i++)
	{
		for (int j = 0; j<n; j++)
		{
			e[i].push_back(i == j);
		}
	}
}
mat tim(mat a, mat b)
{
	mat ret;
	ret.resize(a.size());
	for (int i = 0; i<a.size(); i++)ret[i].resize(b[0].size());
	for (int i = 0; i<a.size(); i++)
	{
		for (int j = 0; j<b[0].size(); j++)
		{
			for (int k = 0; k<a[0].size(); k++)
			{
				ret[i][j] += a[i][k] * b[k][j];
				if (k == ((k >> 3) << 3))ret[i][j] %= mod;
			}
			ret[i][j] %= mod;
		}
	}
	return ret;
}
mat po(mat a, ll b)
{
	if (b == 0)return e;
	mat z = po(a, b / 2);
	z = tim(z, z);
	if (b % 2 == 1)z = tim(z, a);
	return z;
}
int popc[1048576];
int dp[2][1048576][21];
int main()
{
	int num;
	ll kai;
	scanf("%d%I64d%I64d", &num, &kai, &mod);
	makee(num + 1);
	mat t;
	t.resize(num + 1);
	for (int i = 0; i <= num; i++)t[i].resize(num + 1);
	vector<ll>dat;
	for (int i = 0; i < (1 << num); i++)
	{
		ll z;
		scanf("%I64d", &z);
		dat.push_back(z);
	}
	vector<ll>vec;
	for (int i = 0; i <= num; i++)
	{
		ll z;
		scanf("%I64d", &z);
		vec.push_back(z);
	}
	for (int i = 0; i < (1 << num); i++)
	{
		for (int j = 0; j < num; j++)if (i&(1 << j))popc[i]++;
	}
	for (int i = 0; i <= num; i++)
	{
		int n = (1 << i) - 1;
		for (int j = 0; j < (1 << num); j++)
		{
			t[i][popc[j]] += vec[popc[n^j]];
			t[i][popc[j]] %= mod;
		}
	}
	t = po(t, kai);
	int cur = 0;
	for (int i = 0; i < (1 << num); i++)dp[0][i][0] = dat[i];
	for (int i = 0; i < num; i++)
	{
		for (int j = 0; j < (1 << num); j++)
		{
			for (int k = 0; k <= num; k++)
			{
				dp[1 - cur][j][k] = dp[cur][j][k];
				if (k != 0)dp[1 - cur][j][k] = (dp[1 - cur][j][k] + dp[cur][j ^ (1 << i)][k - 1]) % mod;
			}
		}
		for (int j = 0; j < (1 << num); j++)
		{
			for (int k = 0; k <= num; k++)
			{
				dp[cur][j][k] = 0;
			}
		}
		cur = 1 - cur;
	}
	for (int i = 0; i < (1 << num); i++)
	{
		ll ans = 0;
		for (int j = 0; j <= num; j++)
		{
			ans += (ll)(dp[cur][i][j]) *t[j][0];
			ans %= mod;
		}
		printf("%I64d\n", ans);
	}
}


#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<vector<ll> >mat;
ll mod;
mat e;
void makee(int n)
{
	e.clear();
	e.resize(n);
	for (int i = 0; i<n; i++)
	{
		for (int j = 0; j<n; j++)
		{
			e[i].push_back(i == j);
		}
	}
}
mat tim(mat a, mat b)
{
	mat ret;
	ret.resize(a.size());
	for (int i = 0; i<a.size(); i++)ret[i].resize(b[0].size());
	for (int i = 0; i<a.size(); i++)
	{
		for (int j = 0; j<b[0].size(); j++)
		{
			for (int k = 0; k<a[0].size(); k++)
			{
				ret[i][j] += a[i][k] * b[k][j];
				if (k == ((k >> 3) << 3))ret[i][j] %= mod;
			}
			ret[i][j] %= mod;
		}
	}
	return ret;
}
mat po(mat a, ll b)
{
	if (b == 0)return e;
	mat z = po(a, b / 2);
	z = tim(z, z);
	if (b % 2 == 1)z = tim(z, a);
	return z;
}
int popc[1048576];
int dp[2][1048576][21];
int main()
{
	int num;
	ll kai;
	scanf("%d%I64d%I64d", &num, &kai, &mod);
	makee(num + 1);
	mat t;
	t.resize(num + 1);
	for (int i = 0; i <= num; i++)t[i].resize(num + 1);
	vector<ll>dat;
	for (int i = 0; i < (1 << num); i++)
	{
		ll z;
		scanf("%I64d", &z);
		dat.push_back(z);
	}
	vector<ll>vec;
	for (int i = 0; i <= num; i++)
	{
		ll z;
		scanf("%I64d", &z);
		vec.push_back(z);
	}
	for (int i = 0; i < (1 << num); i++)
	{
		for (int j = 0; j < num; j++)if (i&(1 << j))popc[i]++;
	}
	for (int i = 0; i <= num; i++)
	{
		int n = (1 << i) - 1;
		for (int j = 0; j < (1 << num); j++)
		{
			t[i][popc[j]] += vec[popc[n^j]];
			t[i][popc[j]] %= mod;
		}
	}
	t = po(t, kai);
	int cur = 0;
	for (int i = 0; i < (1 << num); i++)dp[0][i][0] = dat[i];
	for (int i = 0; i < num; i++)
	{
		for (int j = 0; j < (1 << num); j++)
		{
			dp[1 - cur][j][0] = dp[cur][j][0];
			for (int k = 1; k <= num;k++)
			{
				dp[1 - cur][j][k] = (dp[cur][j][k] + dp[cur][j ^ (1 << i)][k - 1]) % mod;
			}
		}
		for (int j = 0; j < (1 << num); j++)
		{
			for (int k = 0; k <= num; k++)
			{
				dp[cur][j][k] = 0;
			}
		}
		cur = 1 - cur;
	}
	for (int i = 0; i < (1 << num); i++)
	{
		ll ans = 0;
		for (int j = 0; j <= num; j++)
		{
			ans += (ll)(dp[cur][i][j]) *t[j][0];
			ans %= mod;
		}
		printf("%I64d\n", ans);
	}
}


#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<vector<ll> >mat;
ll mod;
mat e;
void makee(int n)
{
	e.clear();
	e.resize(n);
	for (int i = 0; i<n; i++)
	{
		for (int j = 0; j<n; j++)
		{
			e[i].push_back(i == j);
		}
	}
}
mat tim(mat a, mat b)
{
	mat ret;
	ret.resize(a.size());
	for (int i = 0; i<a.size(); i++)ret[i].resize(b[0].size());
	for (int i = 0; i<a.size(); i++)
	{
		for (int j = 0; j<b[0].size(); j++)
		{
			for (int k = 0; k<a[0].size(); k++)
			{
				ret[i][j] += a[i][k] * b[k][j];
				if (k == ((k >> 3) << 3))ret[i][j] %= mod;
			}
			ret[i][j] %= mod;
		}
	}
	return ret;
}
mat po(mat a, ll b)
{
	if (b == 0)return e;
	mat z = po(a, b / 2);
	z = tim(z, z);
	if (b % 2 == 1)z = tim(z, a);
	return z;
}
int popc[1048576];
ll dp[2][1048576][21];
int main()
{
	int num;
	ll kai;
	scanf("%d%I64d%I64d", &num, &kai, &mod);
	makee(num + 1);
	mat t;
	t.resize(num + 1);
	for (int i = 0; i <= num; i++)t[i].resize(num + 1);
	vector<ll>dat;
	for (int i = 0; i < (1 << num); i++)
	{
		ll z;
		scanf("%I64d", &z);
		dat.push_back(z);
	}
	vector<ll>vec;
	for (int i = 0; i <= num; i++)
	{
		ll z;
		scanf("%I64d", &z);
		vec.push_back(z);
	}
	for (int i = 0; i < (1 << num); i++)
	{
		for (int j = 0; j < num; j++)if (i&(1 << j))popc[i]++;
	}
	for (int i = 0; i <= num; i++)
	{
		int n = (1 << i) - 1;
		for (int j = 0; j < (1 << num); j++)
		{
			t[i][popc[j]] += vec[popc[n^j]];
			t[i][popc[j]] %= mod;
		}
	}
	t = po(t, kai);
	int cur = 0;
	for (int i = 0; i < (1 << num); i++)dp[0][i][0] = dat[i];
	for (int i = 0; i < num; i++)
	{
		for (int j = 0; j < (1 << num); j++)
		{
			for (int k = 0; k <= num; k++)
			{
				dp[1 - cur][j][k] = dp[cur][j][k];
				if (k != 0)dp[1 - cur][j][k] = (dp[1 - cur][j][k] + dp[cur][j ^ (1 << i)][k - 1]) % mod;
			}
		}
		for (int j = 0; j < (1 << num); j++)
		{
			for (int k = 0; k <= num; k++)
			{
				dp[cur][j][k] = 0;
			}
		}
		cur = 1 - cur;
	}
	for (int i = 0; i < (1 << num); i++)
	{
		ll ans = 0;
		for (int j = 0; j <= num; j++)
		{
			ans += dp[cur][i][j] * t[j][0];
			ans %= mod;
		}
		printf("%I64d\n", ans);
	}
}


#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<vector<ll> >mat;
ll mod;
mat e;
void makee(int n)
{
	e.clear();
	e.resize(n);
	for (int i = 0; i<n; i++)
	{
		for (int j = 0; j<n; j++)
		{
			e[i].push_back(i == j);
		}
	}
}
mat tim(mat a, mat b)
{
	mat ret;
	ret.resize(a.size());
	for (int i = 0; i<a.size(); i++)ret[i].resize(b[0].size());
	for (int i = 0; i<a.size(); i++)
	{
		for (int j = 0; j<b[0].size(); j++)
		{
			for (int k = 0; k<a[0].size(); k++)
			{
				ret[i][j] += a[i][k] * b[k][j];
				if (k == ((k >> 3) << 3))ret[i][j] %= mod;
			}
			ret[i][j] %= mod;
		}
	}
	return ret;
}
mat po(mat a, ll b)
{
	if (b == 0)return e;
	mat z = po(a, b / 2);
	z = tim(z, z);
	if (b % 2 == 1)z = tim(z, a);
	return z;
}
int popc[1048576];
int dp[2][1048576][21];
int main()
{
	int num;
	ll kai;
	scanf("%d%I64d%I64d", &num, &kai, &mod);
	makee(num + 1);
	mat t;
	t.resize(num + 1);
	for (int i = 0; i <= num; i++)t[i].resize(num + 1);
	vector<ll>dat;
	for (int i = 0; i < (1 << num); i++)
	{
		ll z;
		scanf("%I64d", &z);
		dat.push_back(z);
	}
	vector<ll>vec;
	for (int i = 0; i <= num; i++)
	{
		ll z;
		scanf("%I64d", &z);
		vec.push_back(z);
	}
	for (int i = 0; i < (1 << num); i++)
	{
		for (int j = 0; j < num; j++)if (i&(1 << j))popc[i]++;
	}
	for (int i = 0; i <= num; i++)
	{
		int n = (1 << i) - 1;
		for (int j = 0; j < (1 << num); j++)
		{
			t[i][popc[j]] += vec[popc[n^j]];
			t[i][popc[j]] %= mod;
		}
	}
	t = po(t, kai);
	int cur = 0;
	for (int i = 0; i < (1 << num); i++)dp[0][i][0] = dat[i];
	for (int i = 0; i < num; i++)
	{
		for (int j = 0; j < (1 << num); j++)
		{
			for (int k = 0; k <= num; k++)
			{
				dp[1 - cur][j][k] = dp[cur][j][k];
			}
			for (int k = 1; k <= num;k++)
			{
				dp[1 - cur][j][k] = (dp[1 - cur][j][k] + dp[cur][j ^ (1 << i)][k - 1]) % mod;
			}
		}
		for (int j = 0; j < (1 << num); j++)
		{
			for (int k = 0; k <= num; k++)
			{
				dp[cur][j][k] = 0;
			}
		}
		cur = 1 - cur;
	}
	for (int i = 0; i < (1 << num); i++)
	{
		ll ans = 0;
		for (int j = 0; j <= num; j++)
		{
			ans += (ll)(dp[cur][i][j]) *t[j][0];
			ans %= mod;
		}
		printf("%I64d\n", ans);
	}
}


#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <math.h>

using namespace std;

typedef long long ll;

const int N = 1 << 21 | 1;

ll n, t, p, m;
int b[31];
ll e[N], y[N], c[N], ans[N];

ll Multi(ll a, ll b, ll c){
    ll ret = 0;
    while(b){
        if(b & 1) ret = (ret + a) % c;
        a = (a + a) % c;
        b >>= 1;
    }
    return ret;
}

ll Pow(ll a, ll b, ll c){
    ll ret = 1;
    while(b){
        if(b & 1) ret = Multi(a, ret, c);
        a = Multi(a, a, c);
        b >>= 1;
    }
    return ret;
}

void fwht(ll a[], int l, int r){
    if(l == r) return ;
    int mid = (l + r) >> 1;
    fwht(a, l, mid);
    fwht(a, mid + 1, r);
    for(int i = l; i <= r; i++)
        if(i <= mid) c[i] = (a[i] + a[i + mid + 1 - l]) % p;
        else c[i] = (a[i - mid - 1 + l] - a[i]) % p;
    for(int i = l; i <= r; i++)
        a[i] = c[i];
}

ll GetInt()
{
    char ch=' ';
    while (!isdigit(ch=getchar())) ;
    ll ans=ch-'0';
    while (isdigit(ch=getchar())) ans=ans*10+ch-'0';
    return ans;
}

int main(){
    cin >> m >> t >> p;
    n = 1 << m;
    p *= n;
    for(int i = 0; i < n; i++)
        e[i] = GetInt();
    for(int i = 0; i <= m; i++)
        b[i] = GetInt();
    for(int i = 0; i < n; i++){
        int bit = 0;
        for(int j = 0; j < m; j++)
            if(i & (1 << j)) bit++;
        y[i] = b[bit];
        //cout << i << " " << y[i] << endl;
    }
    //cout << "--------------------------------\n";
    fwht(y, 0, n - 1);
    for(int i = 0; i < n; i++){
        y[i] = (y[i] + p) % p, y[i] = Pow(y[i], t, p);
        //cout << i << " " << y[i] << endl;
    }
    fwht(e, 0, n - 1);
    //cout << "--------------------------------\n";
    for(int i = 0; i < n; i++){
        //cout << e[i] << " " << y[i] << " " << Multi(e[i], y[i], p) << endl;
        ans[i] = Multi(e[i], y[i], p);
    }
    fwht(ans, 0, n - 1);
    //cout << "--------------------------------\n";
    for(int i = 0; i < n; i++)
        printf("%I64d\n", (ans[i] + p) % p / n);
    return 0;
}


#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <math.h>

using namespace std;

typedef long long ll;

const int N = 1000010;

ll n, t, p, m;
int b[31];
ll e[N], y[N], c[N], ans[N];

ll Multi(ll a, ll b, ll c){
    ll ret = 0;
    while(b){
        if(b & 1) ret = (ret + a) % c;
        a = (a + a) % c;
        b >>= 1;
    }
    return ret;
}

ll Pow(ll a, ll b, ll c){
    ll ret = 1;
    while(b){
        if(b & 1) ret = Multi(a, ret, c);
        a = Multi(a, a, c);
        b >>= 1;
    }
    return ret;
}

void fwht(ll a[], int l, int r){
    if(l == r) return ;
    int mid = (l + r) >> 1;
    fwht(a, l, mid);
    fwht(a, mid + 1, r);
    for(int i = l; i <= r; i++)
        if(i <= mid) c[i] = (a[i] + a[i + mid + 1 - l]) % p;
        else c[i] = (a[i - mid - 1 + l] - a[i]) % p;
    for(int i = l; i <= r; i++)
        a[i] = c[i];
}

void ufwht(ll a[], int r, int l){
    if(l == r) return ;
    int mid = (l + r) >> 1;
    for(int i = l; i <= r; i++){
        if(i <= mid) c[i] = (a[i] + a[i + mid + 1 - l]) % p;
        else c[i]  = (a[i - mid - 1 + l] - a[i]) % p;
    }
    for(int i = l; i <= r; i++)
        a[i] = c[i];
    ufwht(a, l, mid);
    ufwht(a, mid + 1, r);
}

int main(){
    cin >> m >> t >> p;
    n = 1 << m;
    p *= n;
    for(int i = 0; i < n; i++)
        scanf("%I64d", &e[i]);
    for(int i = 0; i <= m; i++)
        scanf("%d", &b[i]);
    for(int i = 0; i < n; i++){
        int bit = 0;
        for(int j = 0; j < m; j++)
            if(i & (1 << j)) bit++;
        y[i] = b[bit];
        //cout << i << " " << y[i] << endl;
    }
    //cout << "--------------------------------\n";
    fwht(y, 0, n - 1);
    for(int i = 0; i < n; i++){
        y[i] = (y[i] + p) % p, y[i] = Pow(y[i], t, p);
        //cout << i << " " << y[i] << endl;
    }
    fwht(e, 0, n - 1);
    //cout << "--------------------------------\n";
    for(int i = 0; i < n; i++){
        //cout << e[i] << " " << y[i] << " " << Multi(e[i], y[i], p) << endl;
        ans[i] = Multi(e[i], y[i], p);
    }
    fwht(ans, 0, n - 1);
    //cout << "--------------------------------\n";
    for(int i = 0; i < n; i++)
        printf("%I64d\n", (ans[i] + p) % p / n);
    return 0;
}


#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <math.h>

using namespace std;

typedef long long ll;

const int N = 1 << 21;

ll n, t, p, m;
int b[31];
ll e[N], y[N], c[N], ans[N];

ll Multi(ll a, ll b, ll c){
    return ((a*b-ll(((long double)a)/p*b+1e-3)*p)%p+p)%p;
}

ll Pow(ll a, ll b, ll c){
    ll ret = 1;
    while(b){
        if(b & 1) ret = Multi(a, ret, c);
        a = Multi(a, a, c);
        b >>= 1;
    }
    return ret;
}

void fwht(ll a[], int l, int r){
    if(l == r) return ;
    int mid = (l + r) >> 1;
    fwht(a, l, mid);
    fwht(a, mid + 1, r);
    for(int i = l; i <= r; i++)
        if(i <= mid) c[i] = (a[i] + a[i + mid + 1 - l]) % p;
        else c[i] = (a[i - mid - 1 + l] - a[i]) % p;
    for(int i = l; i <= r; i++)
        a[i] = c[i];
}

ll GetInt()
{
    char ch=' ';
    while (!isdigit(ch=getchar())) ;
    ll ans=ch-'0';
    while (isdigit(ch=getchar())) ans=ans*10+ch-'0';
    return ans;
}

int main(){
    cin >> m >> t >> p;
    n = 1 << m;
    p *= n;
    for(int i = 0; i < n; i++)
        e[i] = GetInt();
    for(int i = 0; i <= m; i++)
        b[i] = GetInt();
    for(int i = 0; i < n; i++){
        int bit = 0;
        for(int j = 0; j < m; j++)
            if(i & (1 << j)) bit++;
        y[i] = b[bit];
        //cout << i << " " << y[i] << endl;
    }
    //cout << "--------------------------------\n";
    fwht(y, 0, n - 1);
    for(int i = 0; i < n; i++){
        y[i] = (y[i] + p) % p, y[i] = Pow(y[i], t, p);
        //cout << i << " " << y[i] << endl;
    }
    fwht(e, 0, n - 1);
    //cout << "--------------------------------\n";
    for(int i = 0; i < n; i++){
        //cout << e[i] << " " << y[i] << " " << Multi(e[i], y[i], p) << endl;
        ans[i] = Multi(e[i], y[i], p);
    }
    fwht(ans, 0, n - 1);
    //cout << "--------------------------------\n";
    for(int i = 0; i < n; i++)
        printf("%I64d\n", (ans[i] + p) % p / n);
    return 0;
}


#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <math.h>

using namespace std;

typedef long long ll;

const int N = 1<<21;

ll n, t, p, m;
int b[31];
ll e[N], y[N], c[N], ans[N];

ll Multi(ll a, ll b, ll c){
    ll ret = 0;
    while(b){
        if(b & 1) ret = (ret + a) % c;
        a = (a + a) % c;
        b >>= 1;
    }
    return ret;
}

ll Pow(ll a, ll b, ll c){
    ll ret = 1;
    while(b){
        if(b & 1) ret = Multi(a, ret, c);
        a = Multi(a, a, c);
        b >>= 1;
    }
    return ret;
}

void fwht(ll a[], int l, int r){
    if(l == r) return ;
    int mid = (l + r) >> 1;
    fwht(a, l, mid);
    fwht(a, mid + 1, r);
    for(int i = l; i <= r; i++)
        if(i <= mid) c[i] = (a[i] + a[i + mid + 1 - l]) % p;
        else c[i] = (a[i - mid - 1 + l] - a[i]) % p;
    for(int i = l; i <= r; i++)
        a[i] = c[i];
}

void ufwht(ll a[], int r, int l){
    if(l == r) return ;
    int mid = (l + r) >> 1;
    for(int i = l; i <= r; i++){
        if(i <= mid) c[i] = (a[i] + a[i + mid + 1 - l]) % p;
        else c[i]  = (a[i - mid - 1 + l] - a[i]) % p;
    }
    for(int i = l; i <= r; i++)
        a[i] = c[i];
    ufwht(a, l, mid);
    ufwht(a, mid + 1, r);
}

int main(){
    cin >> m >> t >> p;
    n = 1 << m;
    p *= n;
    for(int i = 0; i < n; i++)
        scanf("%I64d", &e[i]);
    for(int i = 0; i <= m; i++)
        scanf("%d", &b[i]);
    for(int i = 0; i < n; i++){
        int bit = 0;
        for(int j = 0; j < m; j++)
            if(i & (1 << j)) bit++;
        y[i] = b[bit];
        //cout << i << " " << y[i] << endl;
    }
    //cout << "--------------------------------\n";
    fwht(y, 0, n - 1);
    for(int i = 0; i < n; i++){
        y[i] = (y[i] + p) % p, y[i] = Pow(y[i], t, p);
        //cout << i << " " << y[i] << endl;
    }
    fwht(e, 0, n - 1);
    //cout << "--------------------------------\n";
    for(int i = 0; i < n; i++){
        //cout << e[i] << " " << y[i] << " " << Multi(e[i], y[i], p) << endl;
        ans[i] = Multi(e[i], y[i], p);
    }
    fwht(ans, 0, n - 1);
    //cout << "--------------------------------\n";
    for(int i = 0; i < n; i++)
        printf("%I64d\n", (ans[i] + p) % p / n);
    return 0;
}


#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <math.h>

using namespace std;

typedef long long ll;

const int N = 1 << 21 | 1;

ll n, t, p, m;
int b[31];
ll e[N], y[N], c[N], ans[N];

ll Multi(ll a, ll b, ll c){
    return ((a*b-ll(((long double)a)/p*b+1e-3)*p)%p+p)%p;
}

ll Pow(ll a, ll b, ll c){
    ll ret = 1;
    while(b){
        if(b & 1) ret = Multi(a, ret, c);
        a = Multi(a, a, c);
        b >>= 1;
    }
    return ret;
}

void fwht(ll a[], int l, int r){
    if(l == r) return ;
    int mid = (l + r) >> 1;
    fwht(a, l, mid);
    fwht(a, mid + 1, r);
    for(int i = l; i <= r; i++)
        if(i <= mid) c[i] = (a[i] + a[i + mid + 1 - l]) % p;
        else c[i] = (a[i - mid - 1 + l] - a[i]) % p;
    for(int i = l; i <= r; i++)
        a[i] = c[i];
}

ll GetInt()
{
    char ch=' ';
    while (!isdigit(ch=getchar())) ;
    ll ans=ch-'0';
    while (isdigit(ch=getchar())) ans=ans*10+ch-'0';
    return ans;
}

int main(){
    cin >> m >> t >> p;
    n = 1 << m;
    p *= n;
    for(int i = 0; i < n; i++)
        e[i] = GetInt();
    for(int i = 0; i <= m; i++)
        b[i] = GetInt();
    for(int i = 0; i < n; i++){
        int bit = 0;
        for(int j = 0; j < m; j++)
            if(i & (1 << j)) bit++;
        y[i] = b[bit];
        //cout << i << " " << y[i] << endl;
    }
    //cout << "--------------------------------\n";
    fwht(y, 0, n - 1);
    for(int i = 0; i < n; i++){
        y[i] = (y[i] + p) % p, y[i] = Pow(y[i], t, p);
        //cout << i << " " << y[i] << endl;
    }
    fwht(e, 0, n - 1);
    //cout << "--------------------------------\n";
    for(int i = 0; i < n; i++){
        //cout << e[i] << " " << y[i] << " " << Multi(e[i], y[i], p) << endl;
        ans[i] = Multi(e[i], y[i], p);
    }
    fwht(ans, 0, n - 1);
    //cout << "--------------------------------\n";
    for(int i = 0; i < n; i++)
        printf("%I64d\n", (ans[i] + p) % p / n);
    return 0;
}


#include <bits/stdc++.h>
//
using namespace std;
//
#define REP(n,i) for(int (i)=0;(i)<(n);(i)++)
#define CDREP(n,i) for(int (i)=((n)-1);(i)>=0;(i)--)
#define CDFOR(s,e,i) for(int i=((e)-1);(i)>=(s);(i)--)
#define _SZ(n) memset((n),0,sizeof(n))
#define _SMO(n) memset((n),-1,sizeof(n))
#define _MC(n,m) memcpy((n),(m),sizeof(n))
#define _F first
#define _S second
#define _MP(a,b) make_pair((a),(b))
#define _PB(a) push_back((a))
#define FOR(x,y) for(__typeof(y.begin())x=y.begin();x!=y.end();x++)
#define IOS ios_base::sync_with_stdio(0);
// Let's Fight!

#define pd "%d"
#define plld "%I64d"

typedef long long ll;

const int MAXM = 22;
const int MAXN = 1111111;

int M, N;
ll T, P;
ll e0[MAXN], b[MAXM];

ll comb[MAXM][MAXM];
ll nowmat[MAXM][MAXM], powmat[MAXM][MAXM], tmpmat[MAXM][MAXM];
int dp1[MAXM][MAXN], dp2[MAXM][MAXN];
ll ans[MAXN];

void matmul(ll a[MAXM][MAXM], ll b[MAXM][MAXM], ll c[MAXM][MAXM])
{
    for(int i=0; i<=M; i++)
    {
        for(int j=0; j<=M; j++)
        {
            tmpmat[i][j] = 0;
            for(int k=0; k<=M; k++)
            {
                tmpmat[i][j] += a[i][k] * b[k][j];
                tmpmat[i][j] %= P;
            }
        }
    }
    for(int i=0; i<=M; i++)
        for(int j=0; j<=M; j++)
            c[i][j] = tmpmat[i][j];
}

ll ncr(int a, int b)
{
    if(a<0||b<0||a<b)return 0;
    return comb[a][b];
}

void make_mat()
{
    comb[0][0] = 1;
    for(int i=1; i<MAXM; i++)
    {
        comb[i][0] = 1;
        for(int j=1; j<=i; j++)
            comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % P;
    }

    for(int i=0; i<=M; i++)
    {
        for(int j=0; j<=M; j++)
        {
            powmat[i][j] = 0;
            int l = max(0, i+j-M), r = min(i, j);
            for(int k=l; k<=r; k++)
            {
                ll del = (ncr(i, k) * ncr(M-i, j-k)) % P;
                del = (del * b[M-i-j+2*k]) % P;
                powmat[i][j] = (powmat[i][j] + del) % P;
            }
        }
    }

    // for(int i=0; i<=M; i++){for(int j=0; j<=M; j++)cout<<powmat[i][j]<<" ";cout<<endl;}

    for(int i=0; i<=M; i++)
        for(int j=0; j<=M; j++)
            nowmat[i][j] = (i==j);

    ll rem = T;
    while(rem > 0LL)
    {
        if(rem & 1LL)
            matmul(nowmat, powmat, nowmat);
        matmul(powmat, powmat, powmat);
        rem >>= 1;
    }
}

void calc_ans()
{
    for(int i=0; i<N; i++)
        dp1[0][i] = e0[i];

    for(int j=1; j<=M; j++)
    {
        int x = 1<<(j-1);
        for(int k=0; k<=j; k++)
        {
            for(int i=0; i<N; i++)
            {
                dp2[k][i] = (ll)dp1[k][i] + (k>0) * dp1[k-1][i^x];
                dp2[k][i] %= P;
            }
        }
        swap(dp1, dp2);
    }

    for(int i=0; i<N; i++)
    {
        for(int k=0; k<=M; k++)
        {
            ans[i] += dp1[k][i] * nowmat[k][0];
            ans[i] %= P;
        }
    }
}

int main()
{
    scanf(pd plld plld, &M, &T, &P);
    N = 1<<M;

    for(int i=0; i<N; i++)
    {
        scanf(plld, &e0[i]);
        e0[i] %= P;
    }
    for(int i=0; i<=M; i++)
    {
        scanf(plld, &b[i]);
        b[i] %= P;
    }

    make_mat();
    calc_ans();

    for(int i=0; i<N; i++)
        printf(plld "\n", ans[i]);

	return 0;
}


#include <bits/stdc++.h>
//
using namespace std;
//
#define REP(n,i) for(int (i)=0;(i)<(n);(i)++)
#define CDREP(n,i) for(int (i)=((n)-1);(i)>=0;(i)--)
#define CDFOR(s,e,i) for(int i=((e)-1);(i)>=(s);(i)--)
#define _SZ(n) memset((n),0,sizeof(n))
#define _SMO(n) memset((n),-1,sizeof(n))
#define _MC(n,m) memcpy((n),(m),sizeof(n))
#define _F first
#define _S second
#define _MP(a,b) make_pair((a),(b))
#define _PB(a) push_back((a))
#define FOR(x,y) for(__typeof(y.begin())x=y.begin();x!=y.end();x++)
#define IOS ios_base::sync_with_stdio(0);
// Let's Fight!

#define pd "%d"
#define plld "%I64d"

typedef long long ll;

const int MAXM = 22;
const int MAXN = 1111111;

int M, N;
ll T, P;
ll e0[MAXN], b[MAXM];

ll comb[MAXM][MAXM];
ll nowmat[MAXM][MAXM], powmat[MAXM][MAXM], tmpmat[MAXM][MAXM];
int dp1[MAXM][MAXN], dp2[MAXM][MAXN];
ll ans[MAXN];

void matmul(ll a[MAXM][MAXM], ll b[MAXM][MAXM], ll c[MAXM][MAXM])
{
    for(int i=0; i<=M; i++)
    {
        for(int j=0; j<=M; j++)
        {
            tmpmat[i][j] = 0;
            for(int k=0; k<=M; k++)
            {
                tmpmat[i][j] += a[i][k] * b[k][j];
                tmpmat[i][j] %= P;
            }
        }
    }
    for(int i=0; i<=M; i++)
        for(int j=0; j<=M; j++)
            c[i][j] = tmpmat[i][j];
}

ll ncr(int a, int b)
{
    if(a<0||b<0||a<b)return 0;
    return comb[a][b];
}

void make_mat()
{
    comb[0][0] = 1;
    for(int i=1; i<MAXM; i++)
    {
        comb[i][0] = 1;
        for(int j=1; j<=i; j++)
            comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % P;
    }

    for(int i=0; i<=M; i++)
    {
        for(int j=0; j<=M; j++)
        {
            powmat[i][j] = 0;
            int l = max(0, i+j-M), r = min(i, j);
            for(int k=l; k<=r; k++)
            {
                ll del = (ncr(i, k) * ncr(M-i, j-k)) % P;
                del = (del * b[M-i-j+2*k]) % P;
                powmat[i][j] = (powmat[i][j] + del) % P;
            }
        }
    }

    for(int i=0; i<=M; i++)
        for(int j=0; j<=M; j++)
            nowmat[i][j] = (i==j);

    ll rem = T;
    while(rem > 0LL)
    {
        if(rem & 1LL)
            matmul(nowmat, powmat, nowmat);
        matmul(powmat, powmat, powmat);
        rem >>= 1;
    }
}

void calc_ans()
{
    for(int i=0; i<N; i++)
        dp1[0][i] = e0[i];

    for(int j=1; j<=M; j++)
    {
        int x = 1<<(j-1);
        for(int k=0; k<=j; k++)
        {
            for(int i=0; i<N; i++)
            {
                dp2[k][i] = ((ll)dp1[k][i] + (k>0 ? dp1[k-1][i^x] : 0)) % P;
            }
        }
        swap(dp1, dp2);
    }

    for(int i=0; i<N; i++)
    {
        for(int k=0; k<=M; k++)
        {
            ans[i] += dp1[k][i] * nowmat[k][0];
            ans[i] %= P;
        }
    }
}

int main()
{
    scanf(pd plld plld, &M, &T, &P);
    N = 1<<M;

    for(int i=0; i<N; i++)
    {
        scanf(plld, &e0[i]);
        e0[i] %= P;
    }
    for(int i=0; i<=M; i++)
    {
        scanf(plld, &b[i]);
        b[i] %= P;
    }

    make_mat();
    calc_ans();

    for(int i=0; i<N; i++)
        printf(plld "\n", ans[i]);

	return 0;
}