#include <algorithm>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

template<const int64_t &MOD>
struct _m_int {
    int64_t val;

    _m_int(int64_t v = 0) {
        if (v < 0) v = v % MOD + MOD;
        if (v >= MOD) v %= MOD;
        val = v;
    }

    static int64_t inv_mod(int64_t a, int64_t m = MOD) {
        // https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm#Example
        int64_t g = m, r = a, x = 0, y = 1;

        while (r != 0) {
            int64_t q = g / r;
            g %= r; swap(g, r);
            x -= q * y; swap(x, y);
        }

        return x < 0 ? x + m : x;
    }

    explicit operator int() const { return val; }
    explicit operator int64_t() const { return val; }

    _m_int& operator+=(const _m_int &other) {
        val -= MOD - other.val;
        if (val < 0) val += MOD;
        return *this;
    }

    _m_int& operator-=(const _m_int &other) {
        val -= other.val;
        if (val < 0) val += MOD;
        return *this;
    }

    static uint64_t fast_mod(uint64_t x, uint64_t m = MOD) {
#if !defined(_WIN32) || defined(_WIN64)
        return x % m;
#endif
        // Optimized mod for Codeforces 32-bit machines.
        // x must be less than 2^32 * m for this to work, so that x / m fits in a 32-bit integer.
        unsigned x_high = x >> 32, x_low = (unsigned) x;
        unsigned quot, rem;
        asm("divl %4\n"
            : "=a" (quot), "=d" (rem)
            : "d" (x_high), "a" (x_low), "r" (m));
        return rem;
    }

    _m_int& operator*=(const _m_int &other) {
        val = fast_mod((uint64_t) val * other.val);
        return *this;
    }

    _m_int& operator/=(const _m_int &other) {
        return *this *= other.inv();
    }

    friend _m_int operator+(const _m_int &a, const _m_int &b) { return _m_int(a) += b; }
    friend _m_int operator-(const _m_int &a, const _m_int &b) { return _m_int(a) -= b; }
    friend _m_int operator*(const _m_int &a, const _m_int &b) { return _m_int(a) *= b; }
    friend _m_int operator/(const _m_int &a, const _m_int &b) { return _m_int(a) /= b; }

    _m_int& operator++() {
        val = val == MOD - 1 ? 0 : val + 1;
        return *this;
    }

    _m_int& operator--() {
        val = val == 0 ? MOD - 1 : val - 1;
        return *this;
    }

    _m_int operator++(int) { _m_int before = *this; ++*this; return before; }
    _m_int operator--(int) { _m_int before = *this; --*this; return before; }

    _m_int operator-() const {
        return val == 0 ? 0 : MOD - val;
    }

    bool operator==(const _m_int &other) const { return val == other.val; }
    bool operator!=(const _m_int &other) const { return val != other.val; }

    _m_int inv() const {
        return inv_mod(val);
    }

    _m_int pow(int64_t p) const {
        if (p < 0)
            return inv().pow(-p);

        _m_int a = *this, result = 1;

        while (p > 0) {
            if (p & 1)
                result *= a;

            a *= a;
            p >>= 1;
        }

        return result;
    }

    friend ostream& operator<<(ostream &os, const _m_int &m) {
        return os << m.val;
    }
};

int64_t EVEN_MOD = 1 << 20;
using even_int = _m_int<EVEN_MOD>;

int64_t ODD_MOD = EVEN_MOD + 1;
using odd_int = _m_int<ODD_MOD>;

// https://csacademy.com/blog/fast-fourier-transform-and-variations-of-it
namespace walsh_hadamard {
    bool is_power_of_two(int n) {
        return (n & (n - 1)) == 0;
    }

    int round_up_power_two(int n) {
        while (n & (n - 1))
            n = (n | (n - 1)) + 1;

        return max(n, 1);
    }

    template<typename T>
    typename enable_if<is_integral<T>::value>::type divide_all(int n, vector<T> &values) {
        for (int i = 0; i < n; i++)
            values[i] >>= __builtin_ctz(n);
    }

    template<typename T>
    typename enable_if<!is_integral<T>::value>::type divide_all(int n, vector<T> &values) {
        T inv_n = T(1) / n;

        for (int i = 0; i < n; i++)
            values[i] *= inv_n;
    }

    template<typename T>
    void fwht_xor(int n, vector<T> &values, bool inverse = false) {
        assert(is_power_of_two(n));
        assert((int) values.size() >= n);

        for (int len = 1; len < n; len *= 2)
            for (int start = 0; start < n; start += 2 * len)
                for (int i = start; i < start + len; i++) {
                    T u = values[i];
                    const T &v = values[i + len];
                    values[i] = u + v;
                    values[i + len] = u - v;
                }

        if (inverse)
            divide_all(n, values);
    }

    // Warning: make sure to select the type `T_out` so that it can contain N^2 * max(left) * max(right).
    // One option is to use doubles and round at the end, since we are simply dividing by a power of two to finish.
    template<typename T_out, typename T_in>
    vector<T_out> xor_convolution(const vector<T_in> &_left, const vector<T_in> &_right) {
        if (_left.empty() || _right.empty())
            return {};

        vector<T_out> left(_left.begin(), _left.end());
        vector<T_out> right(_right.begin(), _right.end());

        int n = left.size();
        int m = right.size();

        int N = round_up_power_two(max(n, m));
        left.resize(N, 0);
        right.resize(N, 0);

        if (left == right) {
            fwht_xor(N, left);
            right = left;
        } else {
            fwht_xor(N, left);
            fwht_xor(N, right);
        }

        for (int i = 0; i < N; i++)
            left[i] *= right[i];

        fwht_xor(N, left, true);
        return left;
    }
}

int64_t inv_mod(int64_t a, int64_t m) {
    // https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm#Example
    int64_t g = m, r = a, x = 0, y = 1;

    while (r != 0) {
        int64_t q = g / r;
        g %= r; swap(g, r);
        x -= q * y; swap(x, y);
    }

    assert(g == 1);
    assert(y == m || y == -m);
    return x < 0 ? x + m : x;
}

// Returns a number that is a1 mod m1 and a2 mod m2. Assumes m1 and m2 are relatively prime.
int64_t chinese_remainder_theorem(int64_t a1, int64_t m1, int64_t a2, int64_t m2) {
    // assert(__gcd(m1, m2) == 1);
    int64_t k = (a2 - a1) % m2 * inv_mod(m1, m2) % m2;
    int64_t result = a1 + k * m1;

    if (result < 0)
        result += m1 * m2;

    assert(0 <= result && result < m1 * m2);
    assert(result % m1 == a1 && result % m2 == a2);
    return result;
}

int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    int N, M;
    int64_t T;
    cin >> M >> T >> ODD_MOD;
    N = 1 << M;
    EVEN_MOD = N;

    while (ODD_MOD % 2 == 0) {
        ODD_MOD /= 2;
        EVEN_MOD *= 2;
    }

    vector<even_int> E_even(N);
    vector<odd_int> E_odd(N);

    for (int i = 0; i < N; i++) {
        int e;
        cin >> e;
        E_even[i] = e;
        E_odd[i] = e;
    }

    vector<int> B(M + 1);

    for (int i = 0; i <= M; i++)
        cin >> B[i];

    vector<even_int> transition_even(N, 0);
    vector<odd_int> transition_odd(N, 0);

    for (int i = 0; i < N; i++) {
        transition_even[i] = B[__builtin_popcount(i)];
        transition_odd[i] = B[__builtin_popcount(i)];
    }

    walsh_hadamard::fwht_xor(N, E_even);
    walsh_hadamard::fwht_xor(N, E_odd);
    walsh_hadamard::fwht_xor(N, transition_even);
    walsh_hadamard::fwht_xor(N, transition_odd);

    for (int i = 0; i < N; i++) {
        E_even[i] *= transition_even[i].pow(T);
        E_odd[i] *= transition_odd[i].pow(T);
    }

    walsh_hadamard::fwht_xor(N, E_even);
    walsh_hadamard::fwht_xor(N, E_odd);

    dbg(EVEN_MOD, ODD_MOD);

    for (int i = 0; i < N; i++) {
        assert(E_even[i].val % N == 0);
        dbg(i, E_even[i], E_odd[i]);
        E_even[i].val /= N;
        E_odd[i].val /= N;
        dbg(i, E_even[i], E_odd[i]);
        int64_t answer = chinese_remainder_theorem(E_even[i].val, EVEN_MOD / N, E_odd[i].val, ODD_MOD);
        cout << answer << '\n';
    }
}


#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int N = 20, MAXN=N+1;
int mod;

struct Matrix{
	ll M[MAXN][MAXN];
	Matrix(){
		memset(M, 0, sizeof(M));
	}
	ll* operator [](int i){
		return M[i];
	}
} T;

Matrix operator *(Matrix &A, Matrix &B){
	Matrix C;
	for (int i=0; i<MAXN; i++) for (int k=0; k<MAXN; k++) for (int j=0; j<MAXN; j++) C[i][j]=(C[i][j] + A[i][k]*B[k][j])%mod;
	return C;
}

Matrix operator ^(Matrix A, ll tav){
	Matrix Ans;
	for (int i=0; i<MAXN; i++) Ans[i][i]=1;
	for (; tav; tav>>=1, A=A*A) if (tav&1) Ans=Ans*A;
	return Ans;
}

ll n, m, k, u, v, x, y, t, a, b, ans;
ll E0[1<<N];
ll B1[MAXN];
ll Comb[MAXN][MAXN];
int dp[N+1][1<<N];

inline int _mod(int x){
	if (x>=mod) x-=mod;
	return x;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>t>>mod;
	for (int i=0; i<(1<<n); i++) cin>>E0[i];
	if (!t){
		for (int i=0; i<(1<<n); i++) cout<<E0[i]<<'\n';
		return 0;
	}
	for (int i=0; i<=n; i++) cin>>B1[i];

	for (int i=0; i<MAXN; i++){
		Comb[i][0]=Comb[i][i]=1;
		for (int j=1; j<i; j++) Comb[i][j]=(Comb[i-1][j-1] + Comb[i-1][j])%mod;
	}

	for (int i=0; i<=n; i++) for (int j=0; j<=n; j++) for (int k=0; k<=n; k++){
		if (i+k-j<0 || i+k-j>n || j+k>n) continue ;
		T[i+k-j][i]=(T[i+k-j][i] + B1[j+k]*(Comb[i][j]*Comb[n-i][k]%mod))%mod;
	}

	T=T^(t-1);
	Matrix B;
	for (int i=0; i<=n; i++) B[0][i]=B1[i];
	B=B*T;

	for (int i=0; i<(1<<n); i++) dp[0][i]=E0[i]%mod;
	for (int i=0; i<n; i++) for (int j=i+1; j; j--) for (int mask=0; mask<(1<<n); mask++) dp[j][mask]=_mod(dp[j][mask] + dp[j-1][mask^(1<<i)]);
	for (int mask=0; mask<(1<<n); mask++){
		ll res=0;
		for (int i=0; i<=n; i++) res=(res + B[0][i]*dp[i][mask])%mod;
		cout<<res<<'\n';
	}

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>

using namespace std;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

using ll = long long;
int const nmax = 20;
int modulo;

struct Matrix{
  int n;
  int m;
  vector<vector<int>> mat;
  Matrix(int n_ = 0, int m_ = 0){
    n = n_;
    m = m_;
    mat.resize(n);
    for(int i = 0; i < n; i++)
      mat[i].resize(m);
  }

  Matrix operator * (Matrix const a) const{
    //assert(m == a.n);
    Matrix result(n, a.m);
    for(int i = 0; i < n; i++)
      for(int j = 0; j < a.m; j++)
        for(int h = 0; h < m; h++) {
          result.mat[i][j] += 1LL * mat[i][h] * a.mat[h][j] % modulo;
          if(modulo <= result.mat[i][j])
            result.mat[i][j] -= modulo;
        }
    return result;
  }
};

Matrix lgpow(Matrix a, int b){
  if(b == 0){
    Matrix result(a.n, a.n);
    for(int i = 0; i < a.n; i++)
      result.mat[i][i] = 1;
    return result;
  } else {
    Matrix result = lgpow(a, b / 2);
    if(b % 2 == 0)
      return result * result;
    else
      return result * result * a;
  }
}
int comb[1 + nmax][1 + nmax];

void computecomb(int modulo){
  comb[0][0] = 1;
  for(int i = 1;i <= nmax; i++) {
    comb[i][0] = 1;
    for(int j = 1;j <= i; j++) {
      comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
      if(modulo <= comb[i][j])
        comb[i][j] -= modulo;
    }
  }
}

int getcomb(int n, int k){
  if(0 <= k && k <= n)
    return comb[n][k];
  else
    return 0;
}

int original[1 + (1<<nmax)], coef[1 + nmax];
int dp[1 + (1<<nmax)][1 + nmax], dp2[1 + (1 << nmax)][1 + nmax];

int main()
{
  int m, t;
  cin >> m >> t >> modulo;
  computecomb(modulo);
  for(int i = 0; i < (1 << m); i++)
    cin >> original[i];
  for(int i = 0; i <= m; i++)
    cin >> coef[i];
  Matrix contrib(1 + m, 1 + m);

  for(int i = 0; i <= m; i++)
    for(int repair = 0; repair <= m - i; repair++)
      for(int smash = 0; smash <= i; smash++)
        if(i + repair - smash <= m) {
          contrib.mat[i][i + repair - smash] += 1LL * getcomb(i, smash) * getcomb(m - i, repair) % modulo * coef[repair + smash] % modulo;
          if(modulo <= contrib.mat[i][i + repair - smash])
            contrib.mat[i][i + repair - smash] -= modulo;
        }

  contrib = lgpow(contrib, t);

  Matrix contribtotal[1 + nmax];
  for(int i = 0; i <= m; i++) {
    contribtotal[i] = Matrix(1 + m, 1 + m);
    contribtotal[i].mat[0][i] = 1;
    contribtotal[i] = contribtotal[i] * contrib;
  }

  for(int i = 0; i <= m; i++)
    coef[i] = contribtotal[i].mat[0][0];

  for(int mask = 0; mask < (1 << m); mask++)
    dp[mask][0] = original[mask];

  for(int i = 1;i <= m; i++) {
    for(int bits = 0; bits <= i; bits++)
      for(int mask = 0; mask < (1 << m); mask++){
        dp2[mask][bits] = dp[mask][bits];
        if(0 < bits) {
          dp2[mask][bits] += dp[mask ^ (1 << (i - 1))][bits - 1];
          if(modulo <= dp2[mask][bits])
            dp2[mask][bits] -= modulo;
        }
      }
    for(int bits = 0; bits <= i; bits++)
      for(int mask = 0; mask < (1 << m); mask++) {
        dp[mask][bits] = dp2[mask][bits];
        dp2[mask][bits] = 0;
      }
  }

  for(int mask = 0; mask < (1 << m); mask++){
    int result = 0;
    for(int bits = 0; bits <= m; bits++) {
      result += 1LL * dp[mask][bits] * coef[bits] % modulo;
      if(modulo <= result)
        result -= modulo;
    }
    cout << result << '\n';
  }
  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>

using namespace std;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

using ll = long long;
int const nmax = 20;
int modulo;

struct Matrix{
  int n;
  int m;
  vector<vector<int>> mat;
  Matrix(int n_ = 0, int m_ = 0){
    n = n_;
    m = m_;
    mat.resize(n);
    for(int i = 0; i < n; i++)
      mat[i].resize(m);
  }

  Matrix operator * (Matrix const a) const{
    //assert(m == a.n);
    Matrix result(n, a.m);
    for(int i = 0; i < n; i++)
      for(int j = 0; j < a.m; j++)
        for(int h = 0; h < m; h++) {
          result.mat[i][j] += 1LL * mat[i][h] * a.mat[h][j] % modulo;
          if(modulo <= result.mat[i][j])
            result.mat[i][j] -= modulo;
        }
    return result;
  }
};

Matrix lgpow(Matrix a, ll b){
  if(b == 0){
    Matrix result(a.n, a.n);
    for(int i = 0; i < a.n; i++)
      result.mat[i][i] = 1;
    return result;
  } else {
    Matrix result = lgpow(a, b / 2);
    if(b % 2 == 0)
      return result * result;
    else
      return result * result * a;
  }
}
int comb[1 + nmax][1 + nmax];

void computecomb(int modulo){
  comb[0][0] = 1;
  for(int i = 1;i <= nmax; i++) {
    comb[i][0] = 1;
    for(int j = 1;j <= i; j++) {
      comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
      if(modulo <= comb[i][j])
        comb[i][j] -= modulo;
    }
  }
}

int getcomb(int n, int k){
  if(0 <= k && k <= n)
    return comb[n][k];
  else
    return 0;
}

int original[1 + (1<<nmax)], coef[1 + nmax];
int dp[1 + (1<<nmax)][1 + nmax], dp2[1 + (1 << nmax)][1 + nmax];

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int m;
  ll t;
  cin >> m >> t >> modulo;
  computecomb(modulo);
  for(int i = 0; i < (1 << m); i++)
    cin >> original[i];
  for(int i = 0; i <= m; i++)
    cin >> coef[i];
  Matrix contrib(1 + m, 1 + m);

  for(int i = 0; i <= m; i++)
    for(int repair = 0; repair <= m - i; repair++)
      for(int smash = 0; smash <= i; smash++)
        if(i + repair - smash <= m) {
          contrib.mat[i][i + repair - smash] += 1LL * getcomb(i, smash) * getcomb(m - i, repair) % modulo * coef[repair + smash] % modulo;
          if(modulo <= contrib.mat[i][i + repair - smash])
            contrib.mat[i][i + repair - smash] -= modulo;
        }

  contrib = lgpow(contrib, t);

  Matrix contribtotal[1 + nmax];
  for(int i = 0; i <= m; i++) {
    contribtotal[i] = Matrix(1 + m, 1 + m);
    contribtotal[i].mat[0][i] = 1;
    contribtotal[i] = contribtotal[i] * contrib;
  }

  for(int i = 0; i <= m; i++)
    coef[i] = contribtotal[i].mat[0][0];

  for(int mask = 0; mask < (1 << m); mask++)
    dp[mask][0] = original[mask] % modulo;

  assert(m < 20);

  for(int i = 1;i <= m; i++) {
    for(int bits = 0; bits <= i; bits++)
      for(int mask = 0; mask < (1 << m); mask++){
        dp2[mask][bits] = dp[mask][bits];
        if(0 < bits) {
          dp2[mask][bits] += dp[mask ^ (1 << (i - 1))][bits - 1];
          if(modulo <= dp2[mask][bits])
            dp2[mask][bits] -= modulo;
        }
      }
    for(int bits = 0; bits <= i; bits++)
      for(int mask = 0; mask < (1 << m); mask++) {
        dp[mask][bits] = dp2[mask][bits];
        dp2[mask][bits] = 0;
      }
  }

  for(int mask = 0; mask < (1 << m); mask++){
    int result = 0;
    for(int bits = 0; bits <= m; bits++) {
      result += 1LL * dp[mask][bits] * coef[bits] % modulo;
      if(modulo <= result)
        result -= modulo;
    }
    cout << result << '\n';
  }
  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>

using namespace std;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

using ll = long long;
int const nmax = 20;
int modulo;

struct Matrix{
  int n;
  int m;
  vector<vector<int>> mat;
  Matrix(int n_ = 0, int m_ = 0){
    n = n_;
    m = m_;
    mat.resize(n);
    for(int i = 0; i < n; i++)
      mat[i].resize(m);
  }

  Matrix operator * (Matrix const a) const{
    //assert(m == a.n);
    Matrix result(n, a.m);
    for(int i = 0; i < n; i++)
      for(int j = 0; j < a.m; j++)
        for(int h = 0; h < m; h++) {
          result.mat[i][j] += 1LL * mat[i][h] * a.mat[h][j] % modulo;
          if(modulo <= result.mat[i][j])
            result.mat[i][j] -= modulo;
        }
    return result;
  }
};

Matrix lgpow(Matrix a, int b){
  if(b == 0){
    Matrix result(a.n, a.n);
    for(int i = 0; i < a.n; i++)
      result.mat[i][i] = 1;
    return result;
  } else {
    Matrix result = lgpow(a, b / 2);
    if(b % 2 == 0)
      return result * result;
    else
      return result * result * a;
  }
}
int comb[1 + nmax][1 + nmax];

void computecomb(int modulo){
  comb[0][0] = 1;
  for(int i = 1;i <= nmax; i++) {
    comb[i][0] = 1;
    for(int j = 1;j <= i; j++) {
      comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
      if(modulo <= comb[i][j])
        comb[i][j] -= modulo;
    }
  }
}

int getcomb(int n, int k){
  if(0 <= k && k <= n)
    return comb[n][k];
  else
    return 0;
}

int original[1 + (1<<nmax)], coef[1 + nmax];
int dp[1 + (1<<nmax)][1 + nmax], dp2[1 + (1 << nmax)][1 + nmax];

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int m, t;
  cin >> m >> t >> modulo;
  computecomb(modulo);
  for(int i = 0; i < (1 << m); i++)
    cin >> original[i];
  for(int i = 0; i <= m; i++)
    cin >> coef[i];
  Matrix contrib(1 + m, 1 + m);

  for(int i = 0; i <= m; i++)
    for(int repair = 0; repair <= m - i; repair++)
      for(int smash = 0; smash <= i; smash++)
        if(i + repair - smash <= m) {
          contrib.mat[i][i + repair - smash] += 1LL * getcomb(i, smash) * getcomb(m - i, repair) % modulo * coef[repair + smash] % modulo;
          if(modulo <= contrib.mat[i][i + repair - smash])
            contrib.mat[i][i + repair - smash] -= modulo;
        }

  contrib = lgpow(contrib, t);

  Matrix contribtotal[1 + nmax];
  for(int i = 0; i <= m; i++) {
    contribtotal[i] = Matrix(1 + m, 1 + m);
    contribtotal[i].mat[0][i] = 1;
    contribtotal[i] = contribtotal[i] * contrib;
  }

  for(int i = 0; i <= m; i++)
    coef[i] = contribtotal[i].mat[0][0];

  for(int mask = 0; mask < (1 << m); mask++)
    dp[mask][0] = original[mask] % modulo;

  for(int i = 1;i <= m; i++) {
    for(int bits = 0; bits <= i; bits++)
      for(int mask = 0; mask < (1 << m); mask++){
        dp2[mask][bits] = dp[mask][bits];
        if(0 < bits) {
          dp2[mask][bits] += dp[mask ^ (1 << (i - 1))][bits - 1];
          if(modulo <= dp2[mask][bits])
            dp2[mask][bits] -= modulo;
        }
      }
    for(int bits = 0; bits <= i; bits++)
      for(int mask = 0; mask < (1 << m); mask++) {
        dp[mask][bits] = dp2[mask][bits];
        dp2[mask][bits] = 0;
      }
  }

  for(int mask = 0; mask < (1 << m); mask++){
    int result = 0;
    for(int bits = 0; bits <= m; bits++) {
      result += 1LL * dp[mask][bits] * coef[bits] % modulo;
      if(modulo <= result)
        result -= modulo;
    }
    cout << result << '\n';
  }
  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>

using namespace std;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

using ll = long long;
int const nmax = 20;
int modulo;

struct Matrix{
  int n;
  int m;
  vector<vector<int>> mat;
  Matrix(int n_ = 0, int m_ = 0){
    n = n_;
    m = m_;
    mat.resize(n);
    for(int i = 0; i < n; i++)
      mat[i].resize(m);
  }

  Matrix operator * (Matrix const a) const{
    //assert(m == a.n);
    Matrix result(n, a.m);
    for(int i = 0; i < n; i++)
      for(int j = 0; j < a.m; j++)
        for(int h = 0; h < m; h++) {
          result.mat[i][j] += 1LL * mat[i][h] * a.mat[h][j] % modulo;
          if(modulo <= result.mat[i][j])
            result.mat[i][j] -= modulo;
        }
    return result;
  }
};

Matrix lgpow(Matrix a, ll b){
  if(b == 0){
    Matrix result(a.n, a.n);
    for(int i = 0; i < a.n; i++)
      result.mat[i][i] = 1;
    return result;
  } else {
    Matrix result = lgpow(a, b / 2);
    if(b % 2 == 0)
      return result * result;
    else
      return result * result * a;
  }
}
int comb[1 + nmax][1 + nmax];

void computecomb(int modulo){
  comb[0][0] = 1;
  for(int i = 1;i <= nmax; i++) {
    comb[i][0] = 1;
    for(int j = 1;j <= i; j++) {
      comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
      if(modulo <= comb[i][j])
        comb[i][j] -= modulo;
    }
  }
}

int getcomb(int n, int k){
  if(0 <= k && k <= n)
    return comb[n][k];
  else
    return 0;
}

int original[1 + (1<<nmax)], coef[1 + nmax];
int dp[1 + (1<<nmax)][1 + nmax], dp2[1 + (1 << nmax)][1 + nmax];

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int m;
  ll t;
  cin >> m >> t >> modulo;
  computecomb(modulo);
  for(int i = 0; i < (1 << m); i++)
    cin >> original[i];
  for(int i = 0; i <= m; i++)
    cin >> coef[i];
  Matrix contrib(1 + m, 1 + m);

  for(int i = 0; i <= m; i++)
    for(int repair = 0; repair <= m - i; repair++)
      for(int smash = 0; smash <= i; smash++)
        if(i + repair - smash <= m) {
          contrib.mat[i][i + repair - smash] += 1LL * getcomb(i, smash) * getcomb(m - i, repair) % modulo * coef[repair + smash] % modulo;
          if(modulo <= contrib.mat[i][i + repair - smash])
            contrib.mat[i][i + repair - smash] -= modulo;
        }

  contrib = lgpow(contrib, t);

  Matrix contribtotal[1 + nmax];
  for(int i = 0; i <= m; i++) {
    contribtotal[i] = Matrix(1 + m, 1 + m);
    contribtotal[i].mat[0][i] = 1;
    contribtotal[i] = contribtotal[i] * contrib;
  }

  for(int i = 0; i <= m; i++)
    coef[i] = contribtotal[i].mat[0][0];

  for(int mask = 0; mask < (1 << m); mask++)
    dp[mask][0] = original[mask] % modulo;

  for(int i = 1;i <= m; i++) {
    for(int bits = 0; bits <= i; bits++)
      for(int mask = 0; mask < (1 << m); mask++){
        dp2[mask][bits] = dp[mask][bits];
        if(0 < bits) {
          dp2[mask][bits] += dp[mask ^ (1 << (i - 1))][bits - 1];
          if(modulo <= dp2[mask][bits])
            dp2[mask][bits] -= modulo;
        }
      }
    for(int bits = 0; bits <= i; bits++)
      for(int mask = 0; mask < (1 << m); mask++) {
        dp[mask][bits] = dp2[mask][bits];
        dp2[mask][bits] = 0;
      }
  }

  for(int mask = 0; mask < (1 << m); mask++){
    int result = 0;
    for(int bits = 0; bits <= m; bits++) {
      result += 1LL * dp[mask][bits] * coef[bits] % modulo;
      if(modulo <= result)
        result -= modulo;
    }
    cout << result << '\n';
  }
  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>

using namespace std;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

using ll = long long;
int const nmax = 20;
int modulo;

struct Matrix{
  int n;
  int m;
  vector<vector<int>> mat;
  Matrix(int n_ = 0, int m_ = 0){
    n = n_;
    m = m_;
    mat.resize(n);
    for(int i = 0; i < n; i++)
      mat[i].resize(m);
  }

  Matrix operator * (Matrix const a) const{
    //assert(m == a.n);
    Matrix result(n, a.m);
    for(int i = 0; i < n; i++)
      for(int j = 0; j < a.m; j++)
        for(int h = 0; h < m; h++) {
          result.mat[i][j] += 1LL * mat[i][h] * a.mat[h][j] % modulo;
          if(modulo <= result.mat[i][j])
            result.mat[i][j] -= modulo;
        }
    return result;
  }
};

Matrix lgpow(Matrix a, ll b){
  if(b == 0){
    Matrix result(a.n, a.n);
    for(int i = 0; i < a.n; i++)
      result.mat[i][i] = 1;
    return result;
  } else {
    Matrix result = lgpow(a, b / 2);
    if(b % 2 == 0)
      return result * result;
    else
      return result * result * a;
  }
}
int comb[1 + nmax][1 + nmax];

void computecomb(int modulo){
  comb[0][0] = 1;
  for(int i = 1;i <= nmax; i++) {
    comb[i][0] = 1;
    for(int j = 1;j <= i; j++) {
      comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
      if(modulo <= comb[i][j])
        comb[i][j] -= modulo;
    }
  }
}

int getcomb(int n, int k){
  if(0 <= k && k <= n)
    return comb[n][k];
  else
    return 0;
}

int original[1 + (1<<nmax)], coef[1 + nmax];
int dp[1 + nmax][1 + (1<<nmax)], dp2[1 + nmax][1 + (1 << nmax)];

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  int m;
  ll t;
  cin >> m >> t >> modulo;
  computecomb(modulo);
  for(int i = 0; i < (1 << m); i++)
    cin >> original[i];
  for(int i = 0; i <= m; i++)
    cin >> coef[i];
  Matrix contrib(1 + m, 1 + m);

  for(int i = 0; i <= m; i++)
    for(int repair = 0; repair <= m - i; repair++)
      for(int smash = 0; smash <= i; smash++)
        if(i + repair - smash <= m) {
          contrib.mat[i][i + repair - smash] += 1LL * getcomb(i, smash) * getcomb(m - i, repair) % modulo * coef[repair + smash] % modulo;
          if(modulo <= contrib.mat[i][i + repair - smash])
            contrib.mat[i][i + repair - smash] -= modulo;
        }

  contrib = lgpow(contrib, t);

  Matrix contribtotal[1 + nmax];
  for(int i = 0; i <= m; i++) {
    contribtotal[i] = Matrix(1 + m, 1 + m);
    contribtotal[i].mat[0][i] = 1;
    contribtotal[i] = contribtotal[i] * contrib;
  }

  for(int i = 0; i <= m; i++)
    coef[i] = contribtotal[i].mat[0][0];

  for(int mask = 0; mask < (1 << m); mask++)
    dp[0][mask] = original[mask] % modulo;

  for(int i = 1;i <= m; i++) {
    for(int bits = 0; bits <= i; bits++)
      for(int mask = 0; mask < (1 << m); mask++){
        dp2[bits][mask] = dp[bits][mask];
        if(0 < bits) {
          dp2[bits][mask] += dp[bits - 1][mask ^ (1 << (i - 1))];
          if(modulo <= dp2[bits][mask])
            dp2[bits][mask] -= modulo;
        }
      }
    for(int bits = 0; bits <= i; bits++)
      for(int mask = 0; mask < (1 << m); mask++) {
        dp[bits][mask] = dp2[bits][mask];
        dp2[bits][mask] = 0;
      }
  }

  for(int mask = 0; mask < (1 << m); mask++){
    int result = 0;
    for(int bits = 0; bits <= m; bits++) {
      result += 1LL * dp[bits][mask] * coef[bits] % modulo;
      if(modulo <= result)
        result -= modulo;
    }
    cout << result << '\n';
  }
  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>

using namespace std;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

using ll = long long;
int const nmax = 20;
int modulo;

struct Matrix{
  int n;
  int m;
  vector<vector<int>> mat;
  Matrix(int n_ = 0, int m_ = 0){
    n = n_;
    m = m_;
    mat.resize(n);
    for(int i = 0; i < n; i++)
      mat[i].resize(m);
  }

  Matrix operator * (Matrix const a) const{
    //assert(m == a.n);
    Matrix result(n, a.m);
    for(int i = 0; i < n; i++)
      for(int j = 0; j < a.m; j++)
        for(int h = 0; h < m; h++) {
          result.mat[i][j] += 1LL * mat[i][h] * a.mat[h][j] % modulo;
          if(modulo <= result.mat[i][j])
            result.mat[i][j] -= modulo;
        }
    return result;
  }
};

Matrix lgpow(Matrix a, int b){
  if(b == 0){
    Matrix result(a.n, a.n);
    for(int i = 0; i < a.n; i++)
      result.mat[i][i] = 1;
    return result;
  } else {
    Matrix result = lgpow(a, b / 2);
    if(b % 2 == 0)
      return result * result;
    else
      return result * result * a;
  }
}
int comb[1 + nmax][1 + nmax];

void computecomb(int modulo){
  comb[0][0] = 1;
  for(int i = 1;i <= nmax; i++) {
    comb[i][0] = 1;
    for(int j = 1;j <= i; j++) {
      comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
      if(modulo <= comb[i][j])
        comb[i][j] -= modulo;
    }
  }
}

int getcomb(int n, int k){
  if(0 <= k && k <= n)
    return comb[n][k];
  else
    return 0;
}

int original[1 + (1<<nmax)], coef[1 + nmax];
int dp[1 + (1<<nmax)][1 + nmax][1 + nmax];

int main()
{
  int m, t;
  cin >> m >> t >> modulo;
  computecomb(modulo);
  for(int i = 0; i < (1 << m); i++)
    cin >> original[i];
  for(int i = 0; i <= m; i++)
    cin >> coef[i];
  Matrix contrib(1 + m, 1 + m);

  for(int i = 0; i <= m; i++)
    for(int repair = 0; repair <= m - i; repair++)
      for(int smash = 0; smash <= i; smash++)
        if(i + repair - smash <= m) {
          contrib.mat[i][i + repair - smash] += 1LL * getcomb(i, smash) * getcomb(m - i, repair) % modulo * coef[(int)fabs(repair - smash)] % modulo;
          if(modulo <= contrib.mat[i][i + repair - smash])
            contrib.mat[i][i + repair - smash] -= modulo;
        }

  contrib = lgpow(contrib, t);

  Matrix contribtotal[1 + nmax];
  for(int i = 0; i <= m; i++) {
    contribtotal[i] = Matrix(1 + m, 1 + m);
    contribtotal[i].mat[0][i] = 1;
    contribtotal[i] = contribtotal[i] * contrib;
  }

  for(int i = 0; i <= m; i++)
    coef[i] = contribtotal[i].mat[0][0];

  for(int mask = 0; mask < (1 << m); mask++)
    dp[mask][0][0] = original[mask];

  for(int i = 1;i <= m; i++)
    for(int bits = 0; bits <= i; bits++)
      for(int mask = 0; mask < (1 << m); mask++){
        dp[mask][i][bits] = dp[mask][i - 1][bits];
        if(0 < bits) {
          dp[mask][i][bits] += dp[mask ^ (1 << (i - 1))][i - 1][bits - 1];
          if(modulo <= dp[mask][i][bits])
            dp[mask][i][bits] -= modulo;
        }
      }

  for(int mask = 0; mask < (1 << m); mask++){
    int result = 0;
    for(int bits = 0; bits <= m; bits++) {
      result += 1LL * dp[mask][m][bits] * coef[bits] % modulo;
      if(modulo <= result)
        result -= modulo;
    }
    cout << result << '\n';
  }
  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>

using namespace std;

#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

using ll = long long;
int const nmax = 20;
int modulo;

struct Matrix{
  int n;
  int m;
  vector<vector<int>> mat;
  Matrix(int n_ = 0, int m_ = 0){
    n = n_;
    m = m_;
    mat.resize(n);
    for(int i = 0; i < n; i++)
      mat[i].resize(m);
  }

  Matrix operator * (Matrix const a) const{
    //assert(m == a.n);
    Matrix result(n, a.m);
    for(int i = 0; i < n; i++)
      for(int j = 0; j < a.m; j++)
        for(int h = 0; h < m; h++) {
          result.mat[i][j] += 1LL * mat[i][h] * a.mat[h][j] % modulo;
          if(modulo <= result.mat[i][j])
            result.mat[i][j] -= modulo;
        }
    return result;
  }
};

Matrix lgpow(Matrix a, int b){
  if(b == 0){
    Matrix result(a.n, a.n);
    for(int i = 0; i < a.n; i++)
      result.mat[i][i] = 1;
    return result;
  } else {
    Matrix result = lgpow(a, b / 2);
    if(b % 2 == 0)
      return result * result;
    else
      return result * result * a;
  }
}
int comb[1 + nmax][1 + nmax];

void computecomb(int modulo){
  comb[0][0] = 1;
  for(int i = 1;i <= nmax; i++) {
    comb[i][0] = 1;
    for(int j = 1;j <= i; j++) {
      comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
      if(modulo <= comb[i][j])
        comb[i][j] -= modulo;
    }
  }
}

int getcomb(int n, int k){
  if(0 <= k && k <= n)
    return comb[n][k];
  else
    return 0;
}

int original[1 + (1<<nmax)], coef[1 + nmax];
int dp[1 + (1<<nmax)][1 + nmax], dp2[1 + (1 << nmax)][1 + nmax];

int main()
{
  int m, t;
  cin >> m >> t >> modulo;
  computecomb(modulo);
  for(int i = 0; i < (1 << m); i++)
    cin >> original[i];
  for(int i = 0; i <= m; i++)
    cin >> coef[i];
  Matrix contrib(1 + m, 1 + m);

  for(int i = 0; i <= m; i++)
    for(int repair = 0; repair <= m - i; repair++)
      for(int smash = 0; smash <= i; smash++)
        if(i + repair - smash <= m) {
          contrib.mat[i][i + repair - smash] += 1LL * getcomb(i, smash) * getcomb(m - i, repair) % modulo * coef[(int)fabs(repair - smash)] % modulo;
          if(modulo <= contrib.mat[i][i + repair - smash])
            contrib.mat[i][i + repair - smash] -= modulo;
        }

  contrib = lgpow(contrib, t);

  Matrix contribtotal[1 + nmax];
  for(int i = 0; i <= m; i++) {
    contribtotal[i] = Matrix(1 + m, 1 + m);
    contribtotal[i].mat[0][i] = 1;
    contribtotal[i] = contribtotal[i] * contrib;
  }

  for(int i = 0; i <= m; i++)
    coef[i] = contribtotal[i].mat[0][0];

  for(int mask = 0; mask < (1 << m); mask++)
    dp[mask][0] = original[mask];

  for(int i = 1;i <= m; i++) {
    for(int bits = 0; bits <= i; bits++)
      for(int mask = 0; mask < (1 << m); mask++){
        dp2[mask][bits] = dp[mask][bits];
        if(0 < bits) {
          dp2[mask][bits] += dp[mask ^ (1 << (i - 1))][bits - 1];
          if(modulo <= dp2[mask][bits])
            dp2[mask][bits] -= modulo;
        }
      }
    for(int bits = 0; bits <= i; bits++)
      for(int mask = 0; mask < (1 << m); mask++) {
        dp[mask][bits] = dp2[mask][bits];
        dp2[mask][bits] = 0;
      }
  }

  for(int mask = 0; mask < (1 << m); mask++){
    int result = 0;
    for(int bits = 0; bits <= m; bits++) {
      result += 1LL * dp[mask][bits] * coef[bits] % modulo;
      if(modulo <= result)
        result -= modulo;
    }
    cout << result << '\n';
  }
  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){
//	int ret=0;
//	while(k){
//		if(k&1) (ret+=x)%=mod;
//		(x+=x)%=mod; k>>=1;
//	} return ret%mod; fast_tle?
    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("%I64d\n",a[i]%mod);
    return 0;
}


// Phoenix

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

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

const int maxn=(1<<20)+10;

ll m,p,a[maxn],b[maxn],c[40];
ll t;

ll Mul(ll a,ll b){
    bool is=((a<0) ^ (b<0));
    a=abs(a);
    b=abs(b);
    ll ans=0;
    while(b){
	if(b&1) ans=(ans+a)%p;
	a=(a+a)%p;
	b>>=1;
    }
    return (is?-1:1)*ans;
}

ll Pow(ll a,ll b){
    ll ans=1;
    while(b){
	if(b&1) ans=Mul(ans,a);
	a=Mul(a,a);
	b>>=1;
    }
    return ans;
}

void transform(ll *a,bool inv){
    int tw=1<<m;
    for(int ln=1;(2*ln)<=tw;ln*=2){
	for(int l=0;l<tw;l+=ln+ln){
	    for(int i=0;i<ln;i++){
		ll x=a[l+i],y=a[l+ln+i];
		a[l+i]=(x+y)%p;
		a[l+ln+i]=(x-y)%p;
	    }
	}
    }
    if(inv){
	for(int i=0;i<tw;i++){
	    a[i]>>=m;
	}
    }
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>m>>t>>p;
    p<<=m;
    for(int i=0;i<(1<<m);i++)
	cin>>a[i];
    for(int i=0;i<=m;i++)
	cin>>c[i];
    for(int i=0;i<(1<<m);i++)
	b[i]=c[__builtin_popcount(i)];
    transform(a,0);
    transform(b,0);
    for(int i=0;i<(1<<m);i++){
	//		cout<<"HEY ";
	//	cout<<a[i]<<" "<<b[i]<<" "<<t<<" "<<Pow(b[i],t)<<endl;
	a[i]=Mul(a[i],Pow(b[i],t));
    }
    transform(a,1);
    for(int i=0;i<(1<<m);i++){
	cout<<a[i]<<"\n";
    }
    return 0;
}


// Phoenix

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

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

const int maxn=(1<<20)+10;

ll m,p,a[maxn],b[maxn],c[40];
ll t;

ll Mul(ll a,ll b){
    return (a*b-(ll)((ld)a*b/p)*p)%p;
}

ll Pow(ll a,ll b){
    ll ans=1;
    while(b){
	if(b&1) ans=Mul(ans,a);
	a=Mul(a,a);
	b>>=1;
    }
    return ans;
}

void transform(ll *a,bool inv){
    int tw=1<<m;
    for(int ln=1;(2*ln)<=tw;ln*=2){
	for(int l=0;l<tw;l+=ln+ln){
	    for(int i=0;i<ln;i++){
		ll x=a[l+i],y=a[l+ln+i];
		a[l+i]=(x+y)%p;
		a[l+ln+i]=(x-y)%p;
	    }
	}
    }
    if(inv){
	for(int i=0;i<tw;i++){
	    if(a[i]<0) a[i]+=p;
	    a[i]>>=m;
	}
    }
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>m>>t>>p;
    p<<=m;
    for(int i=0;i<(1<<m);i++)
	cin>>a[i];
    for(int i=0;i<=m;i++)
	cin>>c[i];
    for(int i=0;i<(1<<m);i++)
	b[i]=c[__builtin_popcount(i)];
    transform(a,0);
    transform(b,0);
    for(int i=0;i<(1<<m);i++){
	a[i]=Mul(a[i],Pow(b[i],t));
    }
    transform(a,1);
    for(int i=0;i<(1<<m);i++){
	cout<<a[i]<<"\n";
    }
    return 0;
}


// Phoenix

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

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

const int maxn=(1<<20)+10;

ll m,p,a[maxn],b[maxn],c[40];
ll t;

ll Mul(ll a,ll b){
    bool is=((a<0) ^ (b<0));
    a=abs(a);
    b=abs(b);
    ll ans=0;
    while(b){
	if(b&1) ans=(ans+a)%p;
	a=(a+a)%p;
	b>>=1;
    }
    return (is?-1:1)*ans;
}

ll Pow(ll a,ll b){
    ll ans=1;
    while(b){
	if(b&1) ans=Mul(ans,a);
	a=Mul(a,a);
	b>>=1;
    }
    return ans;
}

void transform(ll *a,bool inv){
    int tw=1<<m;
    for(int ln=1;(2*ln)<=tw;ln*=2){
	for(int l=0;l<tw;l+=ln+ln){
	    for(int i=0;i<ln;i++){
		ll x=a[l+i],y=a[l+ln+i];
		a[l+i]=(x+y)%p;
		a[l+ln+i]=(x-y)%p;
	    }
	}
    }
    if(inv){
	for(int i=0;i<tw;i++){
	    a[i]>>=m;
	}
    }
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>m>>t>>p;
    p<<=m;
    for(int i=0;i<(1<<m);i++)
	cin>>a[i];
    for(int i=0;i<=m;i++)
	cin>>c[i];
    for(int i=0;i<(1<<m);i++)
	b[i]=c[__builtin_popcount(i)];
    transform(a,0);
    transform(b,0);
    for(int i=0;i<(1<<m);i++){
	//		cout<<"HEY ";
	//	cout<<a[i]<<" "<<b[i]<<" "<<t<<" "<<Pow(b[i],t)<<endl;
	a[i]=Mul(a[i],Pow(b[i],t));
    }
    transform(a,1);
    for(int i=0;i<(1<<m);i++){
	cout<<a[i]<<" ";
    }
    cout<<endl;
    return 0;
}


// Phoenix

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

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

const int maxn=(1<<20)+10;

ll m,p,a[maxn],b[maxn],c[40];
ll t;

ll Mul(ll a,ll b){
    bool is=((a<0) ^ (b<0));
    a=abs(a);
    b=abs(b);
    ll ans=0;
    while(b){
	if(b&1) ans=(ans+a)%p;
	a=(a+a)%p;
	b>>=1;
    }
    return (is?-1:1)*ans;
}

ll Pow(ll a,ll b){
    ll ans=1;
    while(b){
	if(b&1) ans=Mul(ans,a);
	a=Mul(a,a);
	b>>=1;
    }
    return ans;
}

void transform(ll *a,bool inv){
    int tw=1<<m;
    for(int ln=1;(2*ln)<=tw;ln*=2){
	for(int l=0;l<tw;l+=ln+ln){
	    for(int i=0;i<ln;i++){
		ll x=a[l+i],y=a[l+ln+i];
		a[l+i]=(x+y)%p;
		a[l+ln+i]=(x-y)%p;
	    }
	}
    }
    if(inv){
	for(int i=0;i<tw;i++){
	    if(a[i]<0) a[i]+=p;
	    a[i]>>=m;
	}
    }
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>m>>t>>p;
    p<<=m;
    for(int i=0;i<(1<<m);i++)
	cin>>a[i];
    for(int i=0;i<=m;i++)
	cin>>c[i];
    for(int i=0;i<(1<<m);i++)
	b[i]=c[__builtin_popcount(i)];
    transform(a,0);
    transform(b,0);
    for(int i=0;i<(1<<m);i++){
	//		cout<<"HEY ";
	//	cout<<a[i]<<" "<<b[i]<<" "<<t<<" "<<Pow(b[i],t)<<endl;
	a[i]=Mul(a[i],Pow(b[i],t));
    }
    transform(a,1);
    for(int i=0;i<(1<<m);i++){
	cout<<a[i]<<"\n";
    }
    return 0;
}


//Be Name Khoda
/*
tane adami sharifast be jane adamiat
na hamin lebase zibast neshane adamiat
agar adami be cheshmasto dahano goosho bini
che miane naghshe divaro miane adamiat
khoro khabo khashmo shahvat shaghab asto jahlo zolmat
hayavan khabar nadarad ze jahane adamiat
be haghighat adami bash vagarna morgh bashad
ke hami sokhan begooyad be zabane adamiat
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long LL;
typedef LL ll;
typedef double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;

#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (ll i=a;i<b;++i)
#define Ford(i,a,b) for (ll i=a;i>=b;--i)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); }
#define MKP make_pair
#define RETD(x) { cout << fixed << setprecision(12) << x << ' '; } //exit(0); }
#define GEI(x) scanf("%d",&x)
#define GEL(x) scanf("%lld",&x)
#define ALL(x) x.begin(),x.end()
const ll M=2e2+5,LG=40,SM=256,inf=1e9+5;
ll mod=12345;
LL pw(LL a,ll n) { return (n==0?1:pw(a*a%mod,n/2)*(n%2?a:1)%mod); }
#define MOK(x) while (x>=mod) x-=mod;

ll mat[LG],z[LG],res[LG];
ll a[M],ans[M];
ll n,t,p2n;
ll cm[5*LG][5*LG];

void merg(ll m1[LG],ll m2[LG]){
  /*
  //ER("merging");
  //For(i,0,n+1) ER(i<<' '<<m1[i]);
  //For(i,0,n+1) ER(i<<' '<<m2[i]);
  memset(res,0,sizeof res);
  For(i,0,n+1) For(j,0,n+1) For(k,0,min(i,j)+1){
    if (i+j-k>n) continue;
    res[i+j-2*k]+=m1[i]*m2[j]%mod*cm[n][k]%mod*cm[n][i-k]%mod*cm[n][j-k]%mod;
    res[i+j-k]%=mod;
  }
  //For(i,0,n+1) ER(i<<' '<<res[i]);
  */
  for(ll i=0;i<=n;i++){
		res[i]=0;
		for(ll j=0;j<=n;j++){
			for(ll k=0;k<=n;k++){
				if(i+j-k<=n && k<=i && k<=j && 0<=i+j-k){
					res[i]+=( ((m1[j]*m2[i+j-k-k])%mod) * ((cm[i][k]*cm[n-i][j-k])%mod) )%mod;
				}
			}
		}
		res[i]%=mod;
	}
}

void pow(ll t){
  if (t==1) return;
  t--;
  For(i,0,LG) z[i]=mat[i];
  ll zn=1;
  while (zn<=t){
    if (zn&t){
      merg(mat,z);
      For(i,0,LG) mat[i]=res[i];
    }
    merg(z,z);
    For(i,0,LG) z[i]=res[i];
    zn*=2;
  }
}

ll c[M][LG],tmp[M][LG];

void build(ll l=0,ll r=p2n,ll x=n+1){
  //ER(l);ER(r);
  if (l+1==r){
    c[l][0]=a[l];
    return;
  }
  ll len=1<<(x-2);
  build(l,l+len,x-1);
  build(r-len,r,x-1);
  For(i,l,l+len){
    For(j,1,x){
      tmp[i][j]=(c[i][j]+c[i+len][j-1])%mod;
      tmp[i+len][j]=(c[i+len][j]+c[i][j-1])%mod;
    }
  }
  For(i,l,r) For(j,1,x) {
    c[i][j]=tmp[i][j];
    //ER(i << ' ' << j << ' ' << c[i][j]);
  }
}

void do1(){
  build();
  For(i,0,p2n){
    a[i]=0;
    For(j,0,n+1)
      a[i]+=c[i][j]*mat[j]%mod;
    a[i]%=mod;
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin >> n >> t >> mod;
  For(i,0,2*n){
    For(j,0,2*n){
      if (j==0 || j==i) cm[i][j]=1;
      else cm[i][j]=(cm[i-1][j]+cm[i-1][j-1])%mod;
    }
  }
  p2n = (1<<n);
  For(i,0,p2n){
    cin >> a[i];
  }
  For(i,0,n+1) cin >> mat[i];
  //For(i,0,n+1) ER(i << ' ' << mat[i]);
  pow(t);
  //For(i,0,n+1) ER(i << ' ' << mat[i]);
  do1();
  For(i,0,p2n){
    cout << a[i] << ' ';
  }
}


//Be Name Khoda
/*
tane adami sharifast be jane adamiat
na hamin lebase zibast neshane adamiat
agar adami be cheshmasto dahano goosho bini
che miane naghshe divaro miane adamiat
khoro khabo khashmo shahvat shaghab asto jahlo zolmat
hayavan khabar nadarad ze jahane adamiat
be haghighat adami bash vagarna morgh bashad
ke hami sokhan begooyad be zabane adamiat
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long LL;
typedef LL ll;
typedef double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;

#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (ll i=a;i<b;++i)
#define Ford(i,a,b) for (ll i=a;i>=b;--i)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); }
#define MKP make_pair
#define RETD(x) { cout << fixed << setprecision(12) << x << ' '; } //exit(0); }
#define GEI(x) scanf("%d",&x)
#define GEL(x) scanf("%lld",&x)
#define ALL(x) x.begin(),x.end()
const ll M=1e6+5,LG=40,SM=256,inf=1e9+5;
ll mod=12345;
LL pw(LL a,ll n) { return (n==0?1:pw(a*a%mod,n/2)*(n%2?a:1)%mod); }
#define MOK(x) while (x>=mod) x-=mod;

ll mat[LG],z[LG],res[LG];
ll a[M],ans[M];
ll n,t,p2n;
ll cm[5*LG][5*LG];

void merg(ll m1[LG],ll m2[LG]){
  /*
  //ER("merging");
  //For(i,0,n+1) ER(i<<' '<<m1[i]);
  //For(i,0,n+1) ER(i<<' '<<m2[i]);
  memset(res,0,sizeof res);
  For(i,0,n+1) For(j,0,n+1) For(k,0,min(i,j)+1){
    if (i+j-k>n) continue;
    res[i+j-2*k]+=m1[i]*m2[j]%mod*cm[n][k]%mod*cm[n][i-k]%mod*cm[n][j-k]%mod;
    res[i+j-k]%=mod;
  }
  //For(i,0,n+1) ER(i<<' '<<res[i]);
  */
  for(ll i=0;i<=n;i++){
		res[i]=0;
		for(ll j=0;j<=n;j++){
			for(ll k=0;k<=n;k++){
				if(i+j-k<=n && k<=i && k<=j && 0<=i+j-k){
					res[i]+=( ((m1[j]*m2[i+j-k-k])%mod) * ((cm[i][k]*cm[n-i][j-k])%mod) )%mod;
				}
			}
		}
		res[i]%=mod;
	}
}

void pow(ll t){
  if (t==1) return;
  t--;
  For(i,0,LG) z[i]=mat[i];
  ll zn=1;
  while (zn<=t){
    if (zn&t){
      merg(mat,z);
      For(i,0,LG) mat[i]=res[i];
    }
    merg(z,z);
    For(i,0,LG) z[i]=res[i];
    zn*=2;
  }
}

ll c[M][LG],tmp[M][LG];

void build(ll l=0,ll r=p2n,ll x=n+1){
  //ER(l);ER(r);
  if (l+1==r){
    c[l][0]=a[l];
    return;
  }
  ll len=1<<(x-2);
  build(l,l+len,x-1);
  build(r-len,r,x-1);
  For(i,l,l+len){
    For(j,1,x){
      tmp[i][j]=(c[i][j]+c[i+len][j-1])%mod;
      tmp[i+len][j]=(c[i+len][j]+c[i][j-1])%mod;
    }
  }
  For(i,l,r) For(j,1,x) {
    c[i][j]=tmp[i][j];
    //ER(i << ' ' << j << ' ' << c[i][j]);
  }
}

void do1(){
  build();
  For(i,0,p2n){
    a[i]=0;
    For(j,0,n+1)
      a[i]+=c[i][j]*mat[j]%mod;
    a[i]%=mod;
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin >> n >> t >> mod;
  For(i,0,2*n){
    For(j,0,2*n){
      if (j==0 || j==i) cm[i][j]=1;
      else cm[i][j]=(cm[i-1][j]+cm[i-1][j-1])%mod;
    }
  }
  p2n = (1<<n);
  For(i,0,p2n){
    cin >> a[i];
  }
  For(i,0,n+1) cin >> mat[i];
  //For(i,0,n+1) ER(i << ' ' << mat[i]);
  pow(t);
  //For(i,0,n+1) ER(i << ' ' << mat[i]);
  do1();
  For(i,0,p2n){
    cout << a[i] << '\n';
  }
}


//Be Name Khoda
/*
tane adami sharifast be jane adamiat
na hamin lebase zibast neshane adamiat
agar adami be cheshmasto dahano goosho bini
che miane naghshe divaro miane adamiat
khoro khabo khashmo shahvat shaghab asto jahlo zolmat
hayavan khabar nadarad ze jahane adamiat
be haghighat adami bash vagarna morgh bashad
ke hami sokhan begooyad be zabane adamiat
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long LL;
typedef LL ll;
typedef double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;

#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (ll i=a;i<b;++i)
#define Ford(i,a,b) for (ll i=a;i>=b;--i)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); }
#define MKP make_pair
#define RETD(x) { cout << fixed << setprecision(12) << x << ' '; } //exit(0); }
#define GEI(x) scanf("%d",&x)
#define GEL(x) scanf("%lld",&x)
#define ALL(x) x.begin(),x.end()
const ll M=1e6+5,LG=25,SM=256,inf=1e9+5;
ll mod=12345;
LL pw(LL a,ll n) { return (n==0?1:pw(a*a%mod,n/2)*(n%2?a:1)%mod); }
#define MOK(x) while (x>=mod) x-=mod;

ll mat[LG],z[LG],res[LG];
ll a[M],ans[M];
ll n,t,p2n;
ll cm[5*LG][5*LG];

void merg(ll m1[LG],ll m2[LG]){
  /*
  //ER("merging");
  //For(i,0,n+1) ER(i<<' '<<m1[i]);
  //For(i,0,n+1) ER(i<<' '<<m2[i]);
  memset(res,0,sizeof res);
  For(i,0,n+1) For(j,0,n+1) For(k,0,min(i,j)+1){
    if (i+j-k>n) continue;
    res[i+j-2*k]+=m1[i]*m2[j]%mod*cm[n][k]%mod*cm[n][i-k]%mod*cm[n][j-k]%mod;
    res[i+j-k]%=mod;
  }
  //For(i,0,n+1) ER(i<<' '<<res[i]);
  */
  for(ll i=0;i<=n;i++){
		res[i]=0;
		for(ll j=0;j<=n;j++){
			for(ll k=0;k<=n;k++){
				if(i+j-k<=n && k<=i && k<=j && 0<=i+j-k){
					res[i]+=( ((m1[j]*m2[i+j-k-k])%mod) * ((cm[i][k]*cm[n-i][j-k])%mod) )%mod;
				}
			}
		}
		res[i]%=mod;
	}
}

void pow(ll t){
  if (t==1) return;
  t--;
  For(i,0,LG) z[i]=mat[i];
  ll zn=1;
  while (zn<=t){
    if (zn&t){
      merg(mat,z);
      For(i,0,LG) mat[i]=res[i];
    }
    merg(z,z);
    For(i,0,LG) z[i]=res[i];
    zn*=2;
  }
}

ll c[M][LG],tmp[M][LG];

void build(ll l=0,ll r=p2n,ll x=n+1){
  //ER(l);ER(r);
  if (l+1==r){
    c[l][0]=a[l];
    return;
  }
  ll len=1<<(x-2);
  build(l,l+len,x-1);
  build(r-len,r,x-1);
  For(i,l,l+len){
    For(j,1,x){
      tmp[i][j]=(c[i][j]+c[i+len][j-1])%mod;
      tmp[i+len][j]=(c[i+len][j]+c[i][j-1])%mod;
    }
  }
  For(i,l,r) For(j,1,x) {
    c[i][j]=tmp[i][j];
    //ER(i << ' ' << j << ' ' << c[i][j]);
  }
}

void do1(){
  build();
  For(i,0,p2n){
    a[i]=0;
    For(j,0,n+1)
      a[i]+=c[i][j]*mat[j]%mod;
    a[i]%=mod;
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin >> n >> t >> mod;
  For(i,0,2*n){
    For(j,0,2*n){
      if (j==0 || j==i) cm[i][j]=1;
      else cm[i][j]=(cm[i-1][j]+cm[i-1][j-1])%mod;
    }
  }
  p2n = (1<<n);
  For(i,0,p2n){
    cin >> a[i];
  }
  For(i,0,n+1) cin >> mat[i];
  //For(i,0,n+1) ER(i << ' ' << mat[i]);
  pow(t);
  //For(i,0,n+1) ER(i << ' ' << mat[i]);
  do1();
  For(i,0,p2n){
    cout << a[i] << '\n';
  }
}


//Be Name Khoda
/*
tane adami sharifast be jane adamiat
na hamin lebase zibast neshane adamiat
agar adami be cheshmasto dahano goosho bini
che miane naghshe divaro miane adamiat
khoro khabo khashmo shahvat shaghab asto jahlo zolmat
hayavan khabar nadarad ze jahane adamiat
be haghighat adami bash vagarna morgh bashad
ke hami sokhan begooyad be zabane adamiat
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long LL;
typedef LL ll;
typedef double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;

#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (ll i=a;i<b;++i)
#define Ford(i,a,b) for (ll i=a;i>=b;--i)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); }
#define MKP make_pair
#define RETD(x) { cout << fixed << setprecision(12) << x << ' '; } //exit(0); }
#define GEI(x) scanf("%d",&x)
#define GEL(x) scanf("%lld",&x)
#define ALL(x) x.begin(),x.end()
const ll M=1.1e6+5,LG=25,SM=256,inf=1e9+5;
ll mod=12345;
LL pw(LL a,ll n) { return (n==0?1:pw(a*a%mod,n/2)*(n%2?a:1)%mod); }
#define MOK(x) while (x>=mod) x-=mod;

ll mat[LG],z[LG],res[LG];
ll a[M],ans[M];
ll n,t,p2n;
ll cm[5*LG][5*LG];

void merg(ll m1[LG],ll m2[LG]){
  /*
  //ER("merging");
  //For(i,0,n+1) ER(i<<' '<<m1[i]);
  //For(i,0,n+1) ER(i<<' '<<m2[i]);
  memset(res,0,sizeof res);
  For(i,0,n+1) For(j,0,n+1) For(k,0,min(i,j)+1){
    if (i+j-k>n) continue;
    res[i+j-2*k]+=m1[i]*m2[j]%mod*cm[n][k]%mod*cm[n][i-k]%mod*cm[n][j-k]%mod;
    res[i+j-k]%=mod;
  }
  //For(i,0,n+1) ER(i<<' '<<res[i]);
  */
  for(ll i=0;i<=n;i++){
		res[i]=0;
		for(ll j=0;j<=n;j++){
			for(ll k=0;k<=n;k++){
				if(i+j-k<=n && k<=i && k<=j && 0<=i+j-k){
					res[i]+=( ((m1[j]*m2[i+j-k-k])%mod) * ((cm[i][k]*cm[n-i][j-k])%mod) )%mod;
				}
			}
		}
		res[i]%=mod;
	}
}

void pow(ll t){
  if (t==1) return;
  t--;
  For(i,0,LG) z[i]=mat[i];
  ll zn=1;
  while (zn<=t){
    if (zn&t){
      merg(mat,z);
      For(i,0,LG) mat[i]=res[i];
    }
    merg(z,z);
    For(i,0,LG) z[i]=res[i];
    zn*=2;
  }
}

int c[M][LG],tmp[M][LG];

void build(ll l=0,ll r=p2n,ll x=n+1){
  //ER(l);ER(r);
  if (l+1==r){
    c[l][0]=a[l];
    return;
  }
  ll len=1<<(x-2);
  build(l,l+len,x-1);
  build(r-len,r,x-1);
  For(i,l,l+len){
    For(j,1,x){
      tmp[i][j]=(c[i][j]+c[i+len][j-1])%mod;
      tmp[i+len][j]=(c[i+len][j]+c[i][j-1])%mod;
    }
  }
  For(i,l,r) For(j,1,x) {
    c[i][j]=tmp[i][j];
    //ER(i << ' ' << j << ' ' << c[i][j]);
  }
}

void do1(){
  build();
  For(i,0,p2n){
    a[i]=0;
    For(j,0,n+1)
      a[i]+=c[i][j]*mat[j]%mod;
    a[i]%=mod;
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin >> n >> t >> mod;
  For(i,0,2*n){
    For(j,0,2*n){
      if (j==0 || j==i) cm[i][j]=1;
      else cm[i][j]=(cm[i-1][j]+cm[i-1][j-1])%mod;
    }
  }
  p2n = (1<<n);
  For(i,0,p2n){
    cin >> a[i];
  }
  For(i,0,n+1) cin >> mat[i];
  //For(i,0,n+1) ER(i << ' ' << mat[i]);
  pow(t);
  //For(i,0,n+1) ER(i << ' ' << mat[i]);
  do1();
  For(i,0,p2n){
    cout << a[i] << '\n';
  }
}


//Be Name Khoda
/*
tane adami sharifast be jane adamiat
na hamin lebase zibast neshane adamiat
agar adami be cheshmasto dahano goosho bini
che miane naghshe divaro miane adamiat
khoro khabo khashmo shahvat shaghab asto jahlo zolmat
hayavan khabar nadarad ze jahane adamiat
be haghighat adami bash vagarna morgh bashad
ke hami sokhan begooyad be zabane adamiat
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long LL;
typedef LL ll;
typedef double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;

#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (ll i=a;i<b;++i)
#define Ford(i,a,b) for (ll i=a;i>=b;--i)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); }
#define MKP make_pair
#define RETD(x) { cout << fixed << setprecision(12) << x << ' '; } //exit(0); }
#define GEI(x) scanf("%d",&x)
#define GEL(x) scanf("%lld",&x)
#define ALL(x) x.begin(),x.end()
const ll M=2e2+5,LG=40,SM=256,inf=1e9+5;
ll mod=12345;
LL pw(LL a,ll n) { return (n==0?1:pw(a*a%mod,n/2)*(n%2?a:1)%mod); }
#define MOK(x) while (x>=mod) x-=mod;

ll mat[LG],z[LG],res[LG];
ll a[M],ans[M];
ll n,t,p2n;
ll cm[5*LG][5*LG];

void merg(ll m1[LG],ll m2[LG]){
  /*
  //ER("merging");
  //For(i,0,n+1) ER(i<<' '<<m1[i]);
  //For(i,0,n+1) ER(i<<' '<<m2[i]);
  memset(res,0,sizeof res);
  For(i,0,n+1) For(j,0,n+1) For(k,0,min(i,j)+1){
    if (i+j-k>n) continue;
    res[i+j-2*k]+=m1[i]*m2[j]%mod*cm[n][k]%mod*cm[n][i-k]%mod*cm[n][j-k]%mod;
    res[i+j-k]%=mod;
  }
  //For(i,0,n+1) ER(i<<' '<<res[i]);
  */
  for(ll i=0;i<=n;i++){
		res[i]=0;
		for(ll j=0;j<=n;j++){
			for(ll k=0;k<=n;k++){
				if(i+j-k<=n && k<=i && k<=j && 0<=i+j-k){
					res[i]+=( ((m1[j]*m2[i+j-k-k])%mod) * ((cm[i][k]*cm[n-i][j-k])%mod) )%mod;
				}
			}
		}
		res[i]%=mod;
	}
}

void pow(ll t){
  if (t==1) return;
  t--;
  For(i,0,LG) z[i]=mat[i];
  ll zn=1;
  while (zn<=t){
    if (zn&t){
      merg(mat,z);
      For(i,0,LG) mat[i]=res[i];
    }
    merg(z,z);
    For(i,0,LG) z[i]=res[i];
    zn*=2;
  }
}

ll c[M][LG],tmp[M][LG];

void build(ll l=0,ll r=p2n,ll x=n+1){
  //ER(l);ER(r);
  if (l+1==r){
    c[l][0]=a[l];
    return;
  }
  ll len=1<<(x-2);
  build(l,l+len,x-1);
  build(r-len,r,x-1);
  For(i,l,l+len){
    For(j,1,x){
      tmp[i][j]=(c[i][j]+c[i+len][j-1])%mod;
      tmp[i+len][j]=(c[i+len][j]+c[i][j-1])%mod;
    }
  }
  For(i,l,r) For(j,1,x) {
    c[i][j]=tmp[i][j];
    //ER(i << ' ' << j << ' ' << c[i][j]);
  }
}

void do1(){
  build();
  For(i,0,p2n){
    a[i]=0;
    For(j,0,n+1)
      a[i]+=c[i][j]*mat[j]%mod;
    a[i]%=mod;
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin >> n >> t >> mod;
  For(i,0,2*n){
    For(j,0,2*n){
      if (j==0 || j==i) cm[i][j]=1;
      else cm[i][j]=(cm[i-1][j]+cm[i-1][j-1])%mod;
    }
  }
  p2n = (1<<n);
  For(i,0,p2n){
    cin >> a[i];
  }
  For(i,0,n+1) cin >> mat[i];
  //For(i,0,n+1) ER(i << ' ' << mat[i]);
  pow(t);
  //For(i,0,n+1) ER(i << ' ' << mat[i]);
  do1();
  For(i,0,p2n){
    cout << a[i] << '\n';
  }
}


//Be Name Khoda
/*
tane adami sharifast be jane adamiat
na hamin lebase zibast neshane adamiat
agar adami be cheshmasto dahano goosho bini
che miane naghshe divaro miane adamiat
khoro khabo khashmo shahvat shaghab asto jahlo zolmat
hayavan khabar nadarad ze jahane adamiat
be haghighat adami bash vagarna morgh bashad
ke hami sokhan begooyad be zabane adamiat
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> using ordered_multiset =  tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long LL;
typedef LL ll;
typedef double ld;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;

#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (ll i=a;i<b;++i)
#define Ford(i,a,b) for (ll i=a;i>=b;--i)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); }
#define MKP make_pair
#define RETD(x) { cout << fixed << setprecision(12) << x << ' '; } //exit(0); }
#define GEI(x) scanf("%d",&x)
#define GEL(x) scanf("%lld",&x)
#define ALL(x) x.begin(),x.end()
const ll M=1e6+5,LG=25,SM=256,inf=1e9+5;
ll mod=12345;
LL pw(LL a,ll n) { return (n==0?1:pw(a*a%mod,n/2)*(n%2?a:1)%mod); }
#define MOK(x) while (x>=mod) x-=mod;

ll mat[LG],z[LG],res[LG];
ll a[M],ans[M];
ll n,t,p2n;
ll cm[5*LG][5*LG];

void merg(ll m1[LG],ll m2[LG]){
  /*
  //ER("merging");
  //For(i,0,n+1) ER(i<<' '<<m1[i]);
  //For(i,0,n+1) ER(i<<' '<<m2[i]);
  memset(res,0,sizeof res);
  For(i,0,n+1) For(j,0,n+1) For(k,0,min(i,j)+1){
    if (i+j-k>n) continue;
    res[i+j-2*k]+=m1[i]*m2[j]%mod*cm[n][k]%mod*cm[n][i-k]%mod*cm[n][j-k]%mod;
    res[i+j-k]%=mod;
  }
  //For(i,0,n+1) ER(i<<' '<<res[i]);
  */
  for(ll i=0;i<=n;i++){
		res[i]=0;
		for(ll j=0;j<=n;j++){
			for(ll k=0;k<=n;k++){
				if(i+j-k<=n && k<=i && k<=j && 0<=i+j-k){
					res[i]+=( ((m1[j]*m2[i+j-k-k])%mod) * ((cm[i][k]*cm[n-i][j-k])%mod) )%mod;
				}
			}
		}
		res[i]%=mod;
	}
}

void pow(ll t){
  if (t==1) return;
  t--;
  For(i,0,LG) z[i]=mat[i];
  ll zn=1;
  while (zn<=t){
    if (zn&t){
      merg(mat,z);
      For(i,0,LG) mat[i]=res[i];
    }
    merg(z,z);
    For(i,0,LG) z[i]=res[i];
    zn*=2;
  }
}

int c[M][LG],tmp[M][LG];

void build(ll l=0,ll r=p2n,ll x=n+1){
  //ER(l);ER(r);
  if (l+1==r){
    c[l][0]=a[l];
    return;
  }
  ll len=1<<(x-2);
  build(l,l+len,x-1);
  build(r-len,r,x-1);
  For(i,l,l+len){
    For(j,1,x){
      tmp[i][j]=(c[i][j]+c[i+len][j-1])%mod;
      tmp[i+len][j]=(c[i+len][j]+c[i][j-1])%mod;
    }
  }
  For(i,l,r) For(j,1,x) {
    c[i][j]=tmp[i][j];
    //ER(i << ' ' << j << ' ' << c[i][j]);
  }
}

void do1(){
  build();
  For(i,0,p2n){
    a[i]=0;
    For(j,0,n+1)
      a[i]+=c[i][j]*mat[j]%mod;
    a[i]%=mod;
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin >> n >> t >> mod;
  For(i,0,2*n){
    For(j,0,2*n){
      if (j==0 || j==i) cm[i][j]=1;
      else cm[i][j]=(cm[i-1][j]+cm[i-1][j-1])%mod;
    }
  }
  p2n = (1<<n);
  For(i,0,p2n){
    cin >> a[i];
  }
  For(i,0,n+1) cin >> mat[i];
  //For(i,0,n+1) ER(i << ' ' << mat[i]);
  pow(t);
  //For(i,0,n+1) ER(i << ' ' << mat[i]);
  do1();
  For(i,0,p2n){
    cout << a[i] << '\n';
  }
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

typedef long long LL;
typedef long double db;
const int MAXN = 1 << 20 | 1;
LL mod;
void reduce(LL & x) { x += x >> 31 & mod; }
LL mul(const LL x, const LL y) {
	LL t = x * y - (LL) ((db) x * y / mod + 0.5) * mod;
	return t + (t >> 63 & mod);
}
LL pow(LL a, LL b, LL r = 1) {
	for (; b; b >>= 1, a = mul(a, a))
		if (b & 1) r = mul(r, a);
	return r;
}

int m, P, b[MAXN];
LL f[MAXN], g[MAXN], t;

void FWT(LL * A) {
	const int lim = 1 << m;
	for (int mid = 1; mid != lim; mid <<= 1)
		for (int k = 0; k != lim; k += mid << 1)
			for (int l = 0; l != mid; ++l) {
				const LL Y = A[l + k + mid];
				reduce(A[l + k + mid] = A[l + k] - Y);
				reduce(A[l + k] += Y - mod);
			}
}
int main() {
	std::ios_base::sync_with_stdio(false);
	std::cin >> m >> t >> P;
	mod = (LL) P << m;
	const int lim = 1 << m;
	for (int i = 0; i != lim; ++i)
		std::cin >> f[i];
	for (int i = 0; i <= m; ++i)
		std::cin >> b[i];
	for (int i = 0; i != lim; ++i)
		g[i] = b[__builtin_popcount(i)];
	FWT(f); FWT(g);
	for (int i = 0; i != lim; ++i)
		f[i] = pow(g[i], t, f[i]);
	FWT(f);
	for (int i = 0; i != lim; ++i)
		std::cout << (f[i] >> m) << '\n';
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

typedef long long LL;
typedef long double db;
const int MAXN = 1 << 20 | 1;
LL mod;
void reduce(LL & x) { x += x >> 63 & mod; }
LL mul(const LL x, const LL y) {
	LL t = x * y - (LL) ((db) x * y / mod + 0.5) * mod;
	return t + (t >> 63 & mod);
}
LL pow(LL a, LL b, LL r = 1) {
	for (; b; b >>= 1, a = mul(a, a))
		if (b & 1) r = mul(r, a);
	return r;
}

int m, P, b[MAXN];
LL f[MAXN], g[MAXN], t;

void FWT(LL * A) {
	const int lim = 1 << m;
	for (int mid = 1; mid != lim; mid <<= 1)
		for (int k = 0; k != lim; k += mid << 1)
			for (int l = 0; l != mid; ++l) {
				const LL Y = A[l + k + mid];
				reduce(A[l + k + mid] = A[l + k] - Y);
				reduce(A[l + k] += Y - mod);
			}
}
int main() {
	std::ios_base::sync_with_stdio(false);
	std::cin >> m >> t >> P;
	mod = (LL) P << m;
	const int lim = 1 << m;
	for (int i = 0; i != lim; ++i)
		std::cin >> f[i];
	for (int i = 0; i <= m; ++i)
		std::cin >> b[i];
	for (int i = 0; i != lim; ++i)
		g[i] = b[__builtin_popcount(i)];
	FWT(f); FWT(g);
	for (int i = 0; i != lim; ++i)
		f[i] = pow(g[i], t, f[i]);
	FWT(f);
	for (int i = 0; i != lim; ++i)
		std::cout << (f[i] >> m) << '\n';
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

typedef long long LL;
const int MAXN = 1 << 20;
int m, P, b[MAXN];
LL Dollar1, f[MAXN], g[MAXN], t;
inline LL up(LL x) { return x -= Dollar1, x + (x >> 63 & Dollar1); }
inline LL down(const LL x) { return x + (x >> 63 & Dollar1); }
inline LL mul(const LL x, const LL y) {
	LL t = x * y - static_cast<LL> (static_cast<long double> (x) * y / Dollar1 + 0.5) * Dollar1;
	return t + (t >> 63 & Dollar1);
}
inline LL fastpow(LL a, LL b) {
	LL res = 1;
	while (b) {
		if (b & 1) res = mul(res, a);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}
void FWT(LL * A) {
	const int lim = 1 << m;
	for (int mid = 1; mid != lim; mid <<= 1)
		for (int k = 0; k != lim; k += mid << 1)
			for (int l = 0; l != mid; ++l) {
				const LL X = A[l + k], Y = A[l + k + mid];
				A[l + k] = up(X + Y);
				A[l + k + mid] = down(X - Y);
			}
}
int main() {
	scanf("%d%lld%d", &m, &t, &P);
	Dollar1 = static_cast<LL> (P) << m;
	const int lim = 1 << m;
	for (int i = 0; i != lim; ++i) scanf("%lld", f + i);
	for (int i = 0; i <= m; ++i) scanf("%d", b + i);
	for (int i = 0; i != lim; ++i) g[i] = b[__builtin_popcount(i)];
	FWT(f); FWT(g);
	for (int i = 0; i != lim; ++i)
		f[i] = mul(fastpow(g[i], t), f[i]);
	FWT(f);
	for (int i = 0; i != lim; ++i) printf("%lld\n", f[i] >> m);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define count __builtin_popcountll
const int N=20;
int n,t,p,a[1<<N],c[1<<N],b[N+5];
inline int cf(int x,int y){
	return (__int128)x*y%p;
}
inline void fwt(int y[],int len,int opt){
	for (int i=1;i<len;i<<=1)
		for (int j=0;j<len;j+=i<<1)
			for (int k=0;k<i;k++){
				const int u=y[j+k],v=y[j+k+i];
				y[j+k]=(u+v)%p;
				y[j+k+i]=(u-v+p)%p;
			}
	if (opt==-1)for (int i=0;i<len;i++)y[i]/=len;
}
inline int ksm(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=cf(x,x))
		if (y&1)ans=cf(ans,x);
	return ans;
}
signed main(){
	scanf("%lld%lld%lld",&n,&t,&p);p*=n;
	for (int i=0;i<1<<n;i++)scanf("%lld",&a[i]);
	for (int i=0;i<=n;i++)scanf("%lld",&b[i]);
	for (int i=0;i<1<<n;i++)c[i]=b[count(i)];
	fwt(c,1<<n,1);fwt(a,1<<n,1);
	for (int i=0;i<1<<n;i++)a[i]=cf(a[i],ksm(c[i],t));
	fwt(a,1<<n,-1);
	for (int i=0;i<1<<n;i++)printf("%lld\n",a[i]%(p/n));
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define count __builtin_popcountll
const int N=20;
int n,t,p,a[1<<N],c[1<<N],b[N+5];
inline int cf(int x,int y){
	return (__int128)x*y%p;
}
inline void fwt(int y[],int len,int opt){
	for (int i=1;i<len;i<<=1)
		for (int j=0;j<len;j+=i<<1)
			for (int k=0;k<i;k++){
				const int u=y[j+k],v=y[j+k+i];
				y[j+k]=(u+v)%p;
				y[j+k+i]=(u-v+p)%p;
			}
	if (opt==-1)for (int i=0;i<len;i++)y[i]/=len;
}
inline int ksm(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=cf(x,x))
		if (y&1)ans=cf(ans,x);
	return ans;
}
signed main(){
	scanf("%lld%lld%lld",&n,&t,&p);p*=1<<n;
	for (int i=0;i<1<<n;i++)scanf("%lld",&a[i]);
	for (int i=0;i<=n;i++)scanf("%lld",&b[i]);
	for (int i=0;i<1<<n;i++)c[i]=b[count(i)];
	fwt(c,1<<n,1);fwt(a,1<<n,1);
	for (int i=0;i<1<<n;i++)a[i]=cf(a[i],ksm(c[i],t));
	fwt(a,1<<n,-1);
	for (int i=0;i<1<<n;i++)printf("%lld\n",a[i]%(p/(1<<n)));
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxM = 22, maxN = ((1LL << 20) + 1);
ll M, mod, T, N;

int bc[maxM][maxM];
int dp[maxN][2][maxM];
int arr[maxN], b[maxM], p2[maxM];

struct Matrix {
	ll n, m;
	ll val[maxM][maxM];
	Matrix() {
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				val[i][j] = 0;
	}
};

Matrix operator * (Matrix A, Matrix B) {
	Matrix ret; ret.n = 1, ret.m = M;
	for (int k = 0; k <= M; k++) {
		ll vl = 0;
		for (int i = 0; i <= (M - k); i++) {
			ll vl2 = 0;
			for (int j = 0; j <= k; j++) {
				vl2 = (vl2 + (((bc[k][j] * A.val[0][i + j]) % mod) * B.val[0][i + k - j])) % mod;
			}
			vl = (vl + (bc[M - k][i] * vl2) ) % mod;
		}
		vl %= mod;
		if (vl < 0)
			vl += mod;
		ret.val[0][k] = vl;
	}
	return ret;
}

Matrix Pow(Matrix A, ll b) {
	Matrix Temp; Temp.n = 1; Temp.m = M;
	for (int i = 0; i <= M; i++)
		Temp.val[0][i] = (int(i == 0));
	if (b == 0)
		return Temp;
	Matrix res = A;
	for (b--; b; b >>= 1, A = A * A)
		if (b & 1)
			res = res * A;
	return res;
}

/*Mat mul(Mat a, Mat b) {
	Mat ret = __init();
	for (int k = 0; k <= M; k++) {
		ll val = 0;
		for (int i = 0; i <= (M - k); i++) {
			ll val2 = 0;
			for (int j = 0; j <= k; j++) {
				val2 = (val2 + ((bc[k][j] * a[i + j]) * b[i + k - j])) % mod;
			}
			val = (val + (bc[M - k][i] * val2) ) % mod;
		}
		ret[k] = val;
	}
	return ret;
}

Mat Pow(ll K) {
	if (K == 0)
		return B;
	Mat ret;
	ret = Pow(K / 2);
	ret = mul(ret, ret);
	if (K & 1) {
		ret = mul(TB, ret);
	}
	return ret;
}*/

int main() {
	//ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	scanf("%lld%lld%lld", &M, &T, &mod);
	N = (1LL << M);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
		arr[i] %= mod;
		dp[i][0][0] = arr[i];
	}
	bc[0][0] = 1;
	p2[0] = 1;
	for (int i = 1; i <= (M + 1); i++) {
		p2[i] = 2 * p2[i - 1];
		for (int j = 0; j <= i; j++) {
			if (j == 0 || j == i)
				bc[i][j] = 1;
			else
				bc[i][j] = (bc[i - 1][j - 1] + bc[i - 1][j]);
		}
	}
	for (int i = 0; i <= M; i++) {
		scanf("%lld", &b[i]);
		b[i] %= mod;
	}
	ll J = 1;
	for (int j = 1; j <= M; j++) {
		for (int i = 0; i < N; i++) {
			for (int k = 0; k <= M; k++) {
				if (j == 0 && k == 0) {
					dp[i][J][k] = arr[i];
				} else if (j == 0)
					dp[i][J][k] = 0;
				else {
					dp[i][J][k] = (dp[i][1 - J][k] + dp[i ^ (p2[j - 1])][1 - J][k - 1]);
					if (dp[i][J][k] >= mod)
						dp[i][J][k] -= mod;
				}
			}
		}
		J = 1 - J;
	}
 	//
	/*for (int i = 0; i < N; i++) {
		for (int j = 0; j <= M; j++) {
			cout << i << " - " << j << " : " << dp[i][0][j]  << " , " << dp[i][1][j] << endl;
		}
	}*/

	Matrix B; B.n = 1; B.m = M;

	for (int i = 0; i <= M; i++)
		B.val[0][i] = b[i];

	Matrix c = Pow(B, T);

	ll MD = M % 2, ans;
	for (int i = 0; i < N; i++) {
		ans = 0;
		for (int j = 0; j <= M; j++)
			ans = (ans + (c.val[0][j] * dp[i][MD][j])) % mod;
		printf("%lld\n", ans);
	}
	return 0;
	//This is going to be ACC ^^:)
	//28 wrong answers because of cache xD
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxM = 22, maxN = ((1LL << 20) + 1);
ll M, mod, T, N;

int bc[maxM][maxM];
int dp[maxN][2][maxM];
int arr[maxN], b[maxM], p2[maxM];

struct Matrix {
	ll n, m;
	ll val[maxM][maxM];
	Matrix() {
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				val[i][j] = 0;
	}
};

Matrix operator * (Matrix A, Matrix B) {
	Matrix ret; ret.n = 1, ret.m = M;
	for (int k = 0; k <= M; k++) {
		ll vl = 0;
		for (int i = 0; i <= (M - k); i++) {
			ll vl2 = 0;
			for (int j = 0; j <= k; j++) {
				vl2 = (vl2 + (((bc[k][j] * A.val[0][i + j]) % mod) * B.val[0][i + k - j])) % mod;
			}
			vl = (vl + (bc[M - k][i] * vl2) ) % mod;
		}
		vl %= mod;
		if (vl < 0)
			vl += mod;
		ret.val[0][k] = vl;
	}
	return ret;
}

Matrix Pow(Matrix A, ll b) {
	Matrix Temp; Temp.n = 1; Temp.m = M;
	for (int i = 0; i <= M; i++)
		Temp.val[0][i] = (int(i == 0));
	if (b == 0)
		return Temp;
	Matrix res = A;
	for (b--; b; b >>= 1, A = A * A)
		if (b & 1)
			res = res * A;
	return res;
}

/*Mat mul(Mat a, Mat b) {
	Mat ret = __init();
	for (int k = 0; k <= M; k++) {
		ll val = 0;
		for (int i = 0; i <= (M - k); i++) {
			ll val2 = 0;
			for (int j = 0; j <= k; j++) {
				val2 = (val2 + ((bc[k][j] * a[i + j]) * b[i + k - j])) % mod;
			}
			val = (val + (bc[M - k][i] * val2) ) % mod;
		}
		ret[k] = val;
	}
	return ret;
}

Mat Pow(ll K) {
	if (K == 0)
		return B;
	Mat ret;
	ret = Pow(K / 2);
	ret = mul(ret, ret);
	if (K & 1) {
		ret = mul(TB, ret);
	}
	return ret;
}*/

int main() {
	//ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	scanf("%lld%lld%lld", &M, &T, &mod);
	N = (1LL << M);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
		arr[i] %= mod;
		dp[i][0][0] = arr[i];
	}
	bc[0][0] = 1;
	p2[0] = 1;
	for (int i = 1; i <= (M + 1); i++) {
		p2[i] = 2 * p2[i - 1];
		for (int j = 0; j <= i; j++) {
			if (j == 0 || j == i)
				bc[i][j] = 1;
			else
				bc[i][j] = (bc[i - 1][j - 1] + bc[i - 1][j]);
		}
	}
	for (int i = 0; i <= M; i++) {
		scanf("%lld", &b[i]);
		b[i] %= mod;
	}
	ll J = 1;
	for (int j = 1; j <= M; j++) {
		for (int i = 0; i < N; i++) {
			for (int k = 0; k <= M; k++) {
				if (j == 0 && k == 0) {
					dp[i][J][k] = arr[i];
				} else if (j == 0)
					dp[i][J][k] = 0;
				else {
					dp[i][J][k] = (dp[i][1 - J][k] + dp[i ^ (p2[j - 1])][1 - J][k - 1]);
					if (dp[i][J][k] >= mod)
						dp[i][J][k] -= mod;
				}
			}
		}
		J = 1 - J;
	}
 	//
	/*for (int i = 0; i < N; i++) {
		for (int j = 0; j <= M; j++) {
			cout << i << " - " << j << " : " << dp[i][0][j]  << " , " << dp[i][1][j] << endl;
		}
	}*/

	Matrix B; B.n = 1; B.m = M;

	for (int i = 0; i <= M; i++)
		B.val[0][i] = b[i];

	Matrix c = Pow(B, T);

	ll MD = M % 2, ans;
	for (int i = 0; i < N; i++) {
		ans = 0;
		for (int j = 0; j <= M; j++)
			ans = (ans + (c.val[0][j] * dp[i][MD][j])) % mod;
		printf("%lld\n", ans);
	}
	return 0;
	//This is going to be ACC ^^:)
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxM = 22, maxN = ((1LL << 20) + 1);
ll M, mod, T, N;

ll bc[maxM][maxM];
ll dp[maxN][2][maxM];
int arr[maxN], b[maxM], p2[maxM];

struct Matrix {
	ll n, m;
	ll val[maxM][maxM];
	Matrix() {
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				val[i][j] = 0;
	}
};

Matrix operator * (Matrix A, Matrix B) {
	Matrix ret; ret.n = 1, ret.m = M;
	for (int k = 0; k <= M; k++) {
		ll vl = 0;
		for (int i = 0; i <= (M - k); i++) {
			ll vl2 = 0;
			for (int j = 0; j <= k; j++) {
				vl2 = (vl2 + (((bc[k][j] * A.val[0][i + j]) % mod) * B.val[0][i + k - j])) % mod;
			}
			vl = (vl + (bc[M - k][i] * vl2) ) % mod;
		}
		vl %= mod;
		if (vl < 0)
			vl += mod;
		ret.val[0][k] = vl;
	}
	return ret;
}

Matrix Pow(Matrix A, ll b) {
	Matrix Temp; Temp.n = 1; Temp.m = M;
	for (int i = 0; i <= M; i++)
		Temp.val[0][i] = (int(i == 0));
	if (b == 0)
		return Temp;
	Matrix res = A;
	for (b--; b; b >>= 1, A = A * A)
		if (b & 1)
			res = res * A;
	return res;
}

/*Mat mul(Mat a, Mat b) {
	Mat ret = __init();
	for (int k = 0; k <= M; k++) {
		ll val = 0;
		for (int i = 0; i <= (M - k); i++) {
			ll val2 = 0;
			for (int j = 0; j <= k; j++) {
				val2 = (val2 + ((bc[k][j] * a[i + j]) * b[i + k - j])) % mod;
			}
			val = (val + (bc[M - k][i] * val2) ) % mod;
		}
		ret[k] = val;
	}
	return ret;
}

Mat Pow(ll K) {
	if (K == 0)
		return B;
	Mat ret;
	ret = Pow(K / 2);
	ret = mul(ret, ret);
	if (K & 1) {
		ret = mul(TB, ret);
	}
	return ret;
}*/

int main() {
	//ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	scanf("%lld%lld%lld", &M, &T, &mod);
	N = (1LL << M);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
		dp[i][0][0] = arr[i];
	}
	bc[0][0] = 1;
	p2[0] = 1;
	for (int i = 1; i <= (M + 1); i++) {
		p2[i] = 2 * p2[i - 1];
		for (int j = 0; j <= i; j++) {
			if (j == 0 || j == i)
				bc[i][j] = 1;
			else
				bc[i][j] = (bc[i - 1][j - 1] + bc[i - 1][j]);
		}
	}
	for (int i = 0; i <= M; i++) {
		scanf("%lld", &b[i]);
	}
	ll J = 1;
	for (int j = 1; j <= M; j++) {
		for (int i = 0; i < N; i++) {
			for (int k = 0; k <= M; k++) {
				if (j == 0 && k == 0) {
					dp[i][J][k] = arr[i];
				} else if (j == 0)
					dp[i][J][k] = 0;
				else {
					dp[i][J][k] = (dp[i][1 - J][k] + dp[i ^ (p2[j - 1])][1 - J][k - 1]);
					if (dp[i][J][k] >= mod)
						dp[i][J][k] -= mod;
				}
			}
		}
		J = 1 - J;
	}
 	//
	/*for (int i = 0; i < N; i++) {
		for (int j = 0; j <= M; j++) {
			cout << i << " - " << j << " : " << dp[i][0][j]  << " , " << dp[i][1][j] << endl;
		}
	}*/

	Matrix B; B.n = 1; B.m = M;

	for (int i = 0; i <= M; i++)
		B.val[0][i] = b[i];

	Matrix c = Pow(B, T);

	ll MD = M % 2, ans;
	for (int i = 0; i < N; i++) {
		ans = 0;
		for (int j = 0; j <= M; j++)
			ans = (ans + (c.val[0][j] * dp[i][MD][j])) % mod;
		printf("%lld\n", ans);
	}
	return 0;
	//This is going to be ACC ^^:)
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxM = 22, maxN = ((1LL << 20) + 1);
ll M, mod, T, N;

ll bc[maxM][maxM];
ll dp[maxN][2][maxM];
ll arr[maxN], b[maxM], p2[maxM];

struct Matrix {
	ll n, m;
	ll val[maxM][maxM];
	Matrix() {
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				val[i][j] = 0;
	}
};

Matrix operator * (Matrix A, Matrix B) {
	Matrix ret; ret.n = 1, ret.m = M;
	for (int k = 0; k <= M; k++) {
		ll vl = 0;
		for (int i = 0; i <= (M - k); i++) {
			ll vl2 = 0;
			for (int j = 0; j <= k; j++) {
				vl2 = (vl2 + ((bc[k][j] * A.val[0][i + j]) * B.val[0][i + k - j])) % mod;
			}
			vl = (vl + (bc[M - k][i] * vl2) ) % mod;
		}
		ret.val[0][k] = vl;
	}
	return ret;
}

Matrix Pow(Matrix A, ll b) {
	Matrix Temp; Temp.n = 1; Temp.m = M;
	for (int i = 0; i <= M; i++)
		Temp.val[0][i] = (int(i == 0));
	if (b == 0)
		return Temp;
	Matrix res = A;
	for (b--; b; b >>= 1, A = A * A)
		if (b & 1)
			res = res * A;
	return res;
}

/*Mat mul(Mat a, Mat b) {
	Mat ret = __init();
	for (int k = 0; k <= M; k++) {
		ll val = 0;
		for (int i = 0; i <= (M - k); i++) {
			ll val2 = 0;
			for (int j = 0; j <= k; j++) {
				val2 = (val2 + ((bc[k][j] * a[i + j]) * b[i + k - j])) % mod;
			}
			val = (val + (bc[M - k][i] * val2) ) % mod;
		}
		ret[k] = val;
	}
	return ret;
}

Mat Pow(ll K) {
	if (K == 0)
		return B;
	Mat ret;
	ret = Pow(K / 2);
	ret = mul(ret, ret);
	if (K & 1) {
		ret = mul(TB, ret);
	}
	return ret;
}*/

int main() {
	//ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	scanf("%lld%lld%lld", &M, &T, &mod);
	N = (1LL << M);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
		arr[i] %= mod;
		dp[i][0][0] = arr[i];
	}
	bc[0][0] = 1;
	p2[0] = 1;
	for (int i = 1; i <= (M + 1); i++) {
		p2[i] = 2 * p2[i - 1];
		for (int j = 0; j <= i; j++) {
			if (j == 0 || j == i)
				bc[i][j] = 1;
			else
				bc[i][j] = (bc[i - 1][j - 1] + bc[i - 1][j]) % mod;
		}
	}
	for (int i = 0; i <= M; i++) {
		scanf("%lld", &b[i]);
		b[i] = b[i] % mod;
	}
	ll J = 1;
	for (int j = 1; j <= M; j++) {
		for (int i = 0; i < N; i++) {
			for (int k = 0; k <= M; k++) {
				if (j == 0 && k == 0) {
					dp[i][J][k] = arr[i];
				} else if (j == 0)
					dp[i][J][k] = 0;
				else {
					dp[i][J][k] = (dp[i][1 - J][k] + dp[i ^ (p2[j - 1])][1 - J][k - 1]);
					if (dp[i][J][k] >= mod)
						dp[i][J][k] -= mod;
				}
			}
		}
		J = 1 - J;
	}
 	//
	/*for (int i = 0; i < N; i++) {
		for (int j = 0; j <= M; j++) {
			cout << i << " - " << j << " : " << dp[i][0][j]  << " , " << dp[i][1][j] << endl;
		}
	}*/

	Matrix B; B.n = 1; B.m = M;

	for (int i = 0; i <= M; i++)
		B.val[0][i] = b[i];

	Matrix c = Pow(B, T);

	ll MD = M % 2, ans;
	for (int i = 0; i < N; i++) {
		ans = 0;
		for (int j = 0; j <= M; j++)
			ans = (ans + (c.val[0][j] * dp[i][MD][j])) % mod;
		printf("%lld\n", ans);
	}
	return 0;
	//This is going to be ACC ^^:)
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxM = 22, maxN = ((1LL << 20) + 1);
ll M, mod, T, N;

int bc[maxM][maxM];
int dp[maxN][maxM][2];
int arr[maxN], b[maxM], p2[maxM];

struct Matrix {
	ll n, m;
	ll val[maxM][maxM];
	Matrix() {
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				val[i][j] = 0;
	}
};

Matrix operator * (Matrix A, Matrix B) {
	Matrix ret; ret.n = 1, ret.m = M;
	for (int k = 0; k <= M; k++) {
		ll vl = 0;
		for (int i = 0; i <= (M - k); i++) {
			ll vl2 = 0;
			for (int j = 0; j <= k; j++) {
				vl2 = (vl2 + (((bc[k][j] * A.val[0][i + j]) % mod) * B.val[0][i + k - j])) % mod;
			}
			vl = (vl + (bc[M - k][i] * vl2) ) % mod;
		}
		vl %= mod;
		if (vl < 0)
			vl += mod;
		ret.val[0][k] = vl;
	}
	return ret;
}

Matrix Pow(Matrix A, ll b) {
	Matrix Temp; Temp.n = 1; Temp.m = M;
	for (int i = 0; i <= M; i++)
		Temp.val[0][i] = (int(i == 0));
	if (b == 0)
		return Temp;
	Matrix res = A;
	for (b--; b; b >>= 1, A = A * A)
		if (b & 1)
			res = res * A;
	return res;
}

int main() {
	scanf("%lld%lld%lld", &M, &T, &mod);
	N = (1LL << M);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
		arr[i] %= mod;
		dp[i][0][0] = arr[i];
	}
	bc[0][0] = 1;
	p2[0] = 1;
	for (int i = 1; i <= (M + 1); i++) {
		p2[i] = 2 * p2[i - 1];
		for (int j = 0; j <= i; j++) {
			if (j == 0 || j == i)
				bc[i][j] = 1;
			else
				bc[i][j] = (bc[i - 1][j - 1] + bc[i - 1][j]);
		}
	}
	for (int i = 0; i <= M; i++) {
		scanf("%lld", &b[i]);
		b[i] %= mod;
	}
	ll J = 1;
	for (int j = 1; j <= M; j++) {
		for (int i = 0; i < N; i++) {
			for (int k = 0; k <= M; k++) {
				if (j == 0 && k == 0) {
					dp[i][k][J] = arr[i];
				} else if (j == 0)
					dp[i][k][J] = 0;
				else {
					dp[i][k][J] = (dp[i][k][1 - J] + dp[i ^ (p2[j - 1])][k - 1][1 - J]);
					if (dp[i][J][k] >= mod)
						dp[i][J][k] -= mod;
				}
			}
		}
		J = 1 - J;
	}

	Matrix B; B.n = 1; B.m = M;

	for (int i = 0; i <= M; i++)
		B.val[0][i] = b[i];

	Matrix c = Pow(B, T);

	ll MD = M % 2, ans;
	for (int i = 0; i < N; i++) {
		ans = 0;
		for (int j = 0; j <= M; j++)
			ans = (ans + (c.val[0][j] * dp[i][j][MD])) % mod;
		printf("%lld\n", ans);
	}
	return 0;
	//This is going to be ACC ^^:)
	//28 wrong answers because of cache xD
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxM = 22, maxN = ((1LL << 20) + 1);
ll M, mod, T, N;

int bc[maxM][maxM];
int dp[maxN][2][maxM];
int arr[maxN], b[maxM], p2[maxM];

struct Matrix {
	ll n, m;
	ll val[maxM][maxM];
	Matrix() {
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				val[i][j] = 0;
	}
};

Matrix operator * (Matrix A, Matrix B) {
	Matrix ret; ret.n = 1, ret.m = M;
	for (int k = 0; k <= M; k++) {
		ll vl = 0;
		for (int i = 0; i <= (M - k); i++) {
			ll vl2 = 0;
			for (int j = 0; j <= k; j++) {
				vl2 = (vl2 + (((bc[k][j] * A.val[0][i + j]) % mod) * B.val[0][i + k - j])) % mod;
			}
			vl = (vl + (bc[M - k][i] * vl2) ) % mod;
		}
		vl %= mod;
		if (vl < 0)
			vl += mod;
		ret.val[0][k] = vl;
	}
	return ret;
}

Matrix Pow(Matrix A, ll b) {
	Matrix Temp; Temp.n = 1; Temp.m = M;
	for (int i = 0; i <= M; i++)
		Temp.val[0][i] = (int(i == 0));
	if (b == 0)
		return Temp;
	Matrix res = A;
	for (b--; b; b >>= 1, A = A * A)
		if (b & 1)
			res = res * A;
	return res;
}

/*Mat mul(Mat a, Mat b) {
	Mat ret = __init();
	for (int k = 0; k <= M; k++) {
		ll val = 0;
		for (int i = 0; i <= (M - k); i++) {
			ll val2 = 0;
			for (int j = 0; j <= k; j++) {
				val2 = (val2 + ((bc[k][j] * a[i + j]) * b[i + k - j])) % mod;
			}
			val = (val + (bc[M - k][i] * val2) ) % mod;
		}
		ret[k] = val;
	}
	return ret;
}

Mat Pow(ll K) {
	if (K == 0)
		return B;
	Mat ret;
	ret = Pow(K / 2);
	ret = mul(ret, ret);
	if (K & 1) {
		ret = mul(TB, ret);
	}
	return ret;
}*/

int main() {
	//ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	scanf("%lld%lld%lld", &M, &T, &mod);
	N = (1LL << M);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
		arr[i %= mod;
		dp[i][0][0] = arr[i];
	}
	bc[0][0] = 1;
	p2[0] = 1;
	for (int i = 1; i <= (M + 1); i++) {
		p2[i] = 2 * p2[i - 1];
		for (int j = 0; j <= i; j++) {
			if (j == 0 || j == i)
				bc[i][j] = 1;
			else
				bc[i][j] = (bc[i - 1][j - 1] + bc[i - 1][j]);
		}
	}
	for (int i = 0; i <= M; i++) {
		scanf("%lld", &b[i]);
		b[i] %= mod;
	}
	ll J = 1;
	for (int j = 1; j <= M; j++) {
		for (int i = 0; i < N; i++) {
			for (int k = 0; k <= M; k++) {
				if (j == 0 && k == 0) {
					dp[i][J][k] = arr[i];
				} else if (j == 0)
					dp[i][J][k] = 0;
				else {
					dp[i][J][k] = (dp[i][1 - J][k] + dp[i ^ (p2[j - 1])][1 - J][k - 1]);
					if (dp[i][J][k] >= mod)
						dp[i][J][k] -= mod;
				}
			}
		}
		J = 1 - J;
	}
 	//
	/*for (int i = 0; i < N; i++) {
		for (int j = 0; j <= M; j++) {
			cout << i << " - " << j << " : " << dp[i][0][j]  << " , " << dp[i][1][j] << endl;
		}
	}*/

	Matrix B; B.n = 1; B.m = M;

	for (int i = 0; i <= M; i++)
		B.val[0][i] = b[i];

	Matrix c = Pow(B, T);

	ll MD = M % 2, ans;
	for (int i = 0; i < N; i++) {
		ans = 0;
		for (int j = 0; j <= M; j++)
			ans = (ans + (c.val[0][j] * dp[i][MD][j])) % mod;
		printf("%lld\n", ans);
	}
	return 0;
	//This is going to be ACC ^^:)
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxM = 22, maxN = ((1LL << 20) + 1);
ll M, mod, T, N;

int bc[maxM][maxM];
int dp[maxN][2][maxM];
int arr[maxN], b[maxM], p2[maxM];

struct Matrix {
	ll n, m;
	ll val[maxM][maxM];
	Matrix() {
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				val[i][j] = 0;
	}
};

Matrix operator * (Matrix A, Matrix B) {
	Matrix ret; ret.n = 1, ret.m = M;
	for (int k = 0; k <= M; k++) {
		ll vl = 0;
		for (int i = 0; i <= (M - k); i++) {
			ll vl2 = 0;
			for (int j = 0; j <= k; j++) {
				vl2 = (vl2 + (((bc[k][j] * A.val[0][i + j]) % mod) * B.val[0][i + k - j])) % mod;
			}
			vl = (vl + (bc[M - k][i] * vl2) ) % mod;
		}
		vl %= mod;
		if (vl < 0)
			vl += mod;
		ret.val[0][k] = vl;
	}
	return ret;
}

Matrix Pow(Matrix A, ll b) {
	Matrix Temp; Temp.n = 1; Temp.m = M;
	for (int i = 0; i <= M; i++)
		Temp.val[0][i] = (int(i == 0));
	if (b == 0)
		return Temp;
	Matrix res = A;
	for (b--; b; b >>= 1, A = A * A)
		if (b & 1)
			res = res * A;
	return res;
}

/*Mat mul(Mat a, Mat b) {
	Mat ret = __init();
	for (int k = 0; k <= M; k++) {
		ll val = 0;
		for (int i = 0; i <= (M - k); i++) {
			ll val2 = 0;
			for (int j = 0; j <= k; j++) {
				val2 = (val2 + ((bc[k][j] * a[i + j]) * b[i + k - j])) % mod;
			}
			val = (val + (bc[M - k][i] * val2) ) % mod;
		}
		ret[k] = val;
	}
	return ret;
}

Mat Pow(ll K) {
	if (K == 0)
		return B;
	Mat ret;
	ret = Pow(K / 2);
	ret = mul(ret, ret);
	if (K & 1) {
		ret = mul(TB, ret);
	}
	return ret;
}*/

int main() {
	//ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	scanf("%lld%lld%lld", &M, &T, &mod);
	N = (1LL << M);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
		dp[i][0][0] = arr[i];
	}
	bc[0][0] = 1;
	p2[0] = 1;
	for (int i = 1; i <= (M + 1); i++) {
		p2[i] = 2 * p2[i - 1];
		for (int j = 0; j <= i; j++) {
			if (j == 0 || j == i)
				bc[i][j] = 1;
			else
				bc[i][j] = (bc[i - 1][j - 1] + bc[i - 1][j]);
		}
	}
	for (int i = 0; i <= M; i++) {
		scanf("%lld", &b[i]);
	}
	ll J = 1;
	for (int j = 1; j <= M; j++) {
		for (int i = 0; i < N; i++) {
			for (int k = 0; k <= M; k++) {
				if (j == 0 && k == 0) {
					dp[i][J][k] = arr[i];
				} else if (j == 0)
					dp[i][J][k] = 0;
				else {
					dp[i][J][k] = (dp[i][1 - J][k] + dp[i ^ (p2[j - 1])][1 - J][k - 1]);
					if (dp[i][J][k] >= mod)
						dp[i][J][k] -= mod;
				}
			}
		}
		J = 1 - J;
	}
 	//
	/*for (int i = 0; i < N; i++) {
		for (int j = 0; j <= M; j++) {
			cout << i << " - " << j << " : " << dp[i][0][j]  << " , " << dp[i][1][j] << endl;
		}
	}*/

	Matrix B; B.n = 1; B.m = M;

	for (int i = 0; i <= M; i++)
		B.val[0][i] = b[i];

	Matrix c = Pow(B, T);

	ll MD = M % 2, ans;
	for (int i = 0; i < N; i++) {
		ans = 0;
		for (int j = 0; j <= M; j++)
			ans = (ans + (c.val[0][j] * dp[i][MD][j])) % mod;
		printf("%lld\n", ans);
	}
	return 0;
	//This is going to be ACC ^^:)
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxM = 22, maxN = ((1LL << 20) + 1);
ll M, mod, T, N;

int bc[maxM][maxM];
int dp[maxN][2][maxM];
int arr[maxN], b[maxM], p2[maxM];

struct Matrix {
	ll n, m;
	ll val[maxM][maxM];
	Matrix() {
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				val[i][j] = 0;
	}
};

Matrix operator * (Matrix A, Matrix B) {
	Matrix ret; ret.n = 1, ret.m = M;
	for (int k = 0; k <= M; k++) {
		ll vl = 0;
		for (int i = 0; i <= (M - k); i++) {
			ll vl2 = 0;
			for (int j = 0; j <= k; j++) {
				vl2 = (vl2 + (((bc[k][j] * A.val[0][i + j]) % mod) * B.val[0][i + k - j])) % mod;
			}
			vl = (vl + (bc[M - k][i] * vl2) ) % mod;
		}
		vl %= mod;
		if (vl < 0)
			vl += mod;
		ret.val[0][k] = vl;
	}
	return ret;
}

Matrix Pow(Matrix A, ll b) {
	Matrix Temp; Temp.n = 1; Temp.m = M;
	for (int i = 0; i <= M; i++)
		Temp.val[0][i] = (int(i == 0));
	if (b == 0)
		return Temp;
	Matrix res = A;
	for (b--; b; b >>= 1, A = A * A)
		if (b & 1)
			res = res * A;
	return res;
}

ll read_int(){
	char r;
	bool start=false,neg=false;
	long long int ret=0;
	while(true){
		r=getchar();
		if((r-'0'<0 || r-'0'>9) && r!='-' && !start){
			continue;
		}
		if((r-'0'<0 || r-'0'>9) && r!='-' && start){
			break;
		}
		if(start)ret*=10;
		start=true;
		if(r=='-')neg=true;
		else ret+=r-'0';
	}
	if(!neg)
		return ret;
	else
		return -ret;
}

int main() {
	M = read_int();
	T = read_int();
	mod = read_int();
	N = (1LL << M);
	for (int i = 0; i < N; i++) {
		arr[i] = read_int();
		arr[i] %= mod;
		dp[i][0][0] = arr[i];
	}
	bc[0][0] = 1;
	p2[0] = 1;
	for (int i = 1; i <= (M + 1); i++) {
		p2[i] = 2 * p2[i - 1];
		for (int j = 0; j <= i; j++) {
			if (j == 0 || j == i)
				bc[i][j] = 1;
			else
				bc[i][j] = (bc[i - 1][j - 1] + bc[i - 1][j]);
		}
	}
	for (int i = 0; i <= M; i++) {
		b[i] = read_int();
		b[i] %= mod;
	}
	ll J = 1;
	for (int j = 1; j <= M; j++) {
		for (int i = 0; i < N; i++) {
			for (int k = 0; k <= M; k++) {
				if (j == 0 && k == 0) {
					dp[i][J][k] = arr[i];
				} else if (j == 0)
					dp[i][J][k] = 0;
				else {
					dp[i][J][k] = (dp[i][1 - J][k] + dp[i ^ (p2[j - 1])][1 - J][k - 1]);
					if (dp[i][J][k] >= mod)
						dp[i][J][k] -= mod;
				}
			}
		}
		J = 1 - J;
	}
 	//
	/*for (int i = 0; i < N; i++) {
		for (int j = 0; j <= M; j++) {
			cout << i << " - " << j << " : " << dp[i][0][j]  << " , " << dp[i][1][j] << endl;
		}
	}*/

	Matrix B; B.n = 1; B.m = M;

	for (int i = 0; i <= M; i++)
		B.val[0][i] = b[i];

	Matrix c = Pow(B, T);

	ll MD = M % 2, ans;
	for (int i = 0; i < N; i++) {
		ans = 0;
		for (int j = 0; j <= M; j++)
			ans = (ans + (c.val[0][j] * dp[i][MD][j])) % mod;
		printf("%lld\n", ans);
	}
	return 0;
	//This is going to be ACC ^^:)
	//28 wrong answers because of cache xD
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxM = 22, maxN = ((1LL << 20) + 1);
ll M, mod, T, N;

int bc[maxM][maxM];
int dp[maxN][2][maxM];
int arr[maxN], b[maxM], p2[maxM];

struct Matrix {
	ll n, m;
	ll val[maxM][maxM];
	Matrix() {
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				val[i][j] = 0;
	}
};

Matrix operator * (Matrix A, Matrix B) {
	Matrix ret; ret.n = 1, ret.m = M;
	for (int k = 0; k <= M; k++) {
		ll vl = 0;
		for (int i = 0; i <= (M - k); i++) {
			ll vl2 = 0;
			for (int j = 0; j <= k; j++) {
				vl2 = (vl2 + (((bc[k][j] * A.val[0][i + j]) % mod) * B.val[0][i + k - j])) % mod;
			}
			vl = (vl + (bc[M - k][i] * vl2) ) % mod;
		}
		vl %= mod;
		if (vl < 0)
			vl += mod;
		ret.val[0][k] = vl;
	}
	return ret;
}

Matrix Pow(Matrix A, ll b) {
	Matrix Temp; Temp.n = 1; Temp.m = M;
	for (int i = 0; i <= M; i++)
		Temp.val[0][i] = (int(i == 0));
	if (b == 0)
		return Temp;
	Matrix res = A;
	for (b--; b; b >>= 1, A = A * A)
		if (b & 1)
			res = res * A;
	return res;
}

int main() {
	scanf("%lld%lld%lld", &M, &T, &mod);
	N = (1LL << M);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
		arr[i] %= mod;
		dp[i][0][0] = arr[i];
	}
	bc[0][0] = 1;
	p2[0] = 1;
	for (int i = 1; i <= (M + 1); i++) {
		p2[i] = 2 * p2[i - 1];
		for (int j = 0; j <= i; j++) {
			if (j == 0 || j == i)
				bc[i][j] = 1;
			else
				bc[i][j] = (bc[i - 1][j - 1] + bc[i - 1][j]);
		}
	}
	for (int i = 0; i <= M; i++) {
		scanf("%lld", &b[i]);
		b[i] %= mod;
	}
	ll J = 1;
	for (int j = 1; j <= M; j++) {
		for (int i = 0; i < N; i++) {
			for (int k = 0; k <= M; k++) {
				if (j == 0 && k == 0) {
					dp[i][J][k] = arr[i];
				} else if (j == 0)
					dp[i][J][k] = 0;
				else {
					dp[i][J][k] = (dp[i][1 - J][k] + dp[i ^ (p2[j - 1])][1 - J][k - 1]);
					if (dp[i][J][k] >= mod)
						dp[i][J][k] -= mod;
				}
			}
		}
		J = 1 - J;
	}

	Matrix B; B.n = 1; B.m = M;

	for (int i = 0; i <= M; i++)
		B.val[0][i] = b[i];

	Matrix c = Pow(B, T);

	ll MD = M % 2, ans;
	for (int i = 0; i < N; i++) {
		ans = 0;
		for (int j = 0; j <= M; j++)
			ans = (ans + (c.val[0][j] * dp[i][MD][j])) % mod;
		printf("%lld\n", ans);
	}
	return 0;
	//This is going to be ACC ^^:)
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll maxM = 21, maxN = ((1LL << 20) + 1);
ll M, mod, T, N;

int bc[maxM][maxM];
int dp[maxN][maxM][2];
int arr[maxN], b[maxM], p2[maxM];

struct Matrix {
	ll n, m;
	ll val[maxM][maxM];
	Matrix() {
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				val[i][j] = 0;
	}
};

Matrix operator * (Matrix A, Matrix B) {
	Matrix ret; ret.n = 1, ret.m = M;
	for (int k = 0; k <= M; k++) {
		ll vl = 0;
		for (int i = 0; i <= (M - k); i++) {
			ll vl2 = 0;
			for (int j = 0; j <= k; j++) {
				vl2 = (vl2 + (((bc[k][j] * A.val[0][i + j]) % mod) * B.val[0][i + k - j])) % mod;
			}
			vl = (vl + (bc[M - k][i] * vl2) ) % mod;
		}
		vl %= mod;
		if (vl < 0)
			vl += mod;
		ret.val[0][k] = vl;
	}
	return ret;
}

Matrix Pow(Matrix A, ll b) {
	Matrix Temp; Temp.n = 1; Temp.m = M;
	for (int i = 0; i <= M; i++)
		Temp.val[0][i] = (int(i == 0));
	if (b == 0)
		return Temp;
	Matrix res = A;
	for (b--; b; b >>= 1, A = A * A)
		if (b & 1)
			res = res * A;
	return res;
}

int main() {
	scanf("%lld%lld%lld", &M, &T, &mod);
	N = (1LL << M);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
		arr[i] %= mod;
		dp[i][0][0] = arr[i];
	}
	bc[0][0] = 1;
	p2[0] = 1;
	for (int i = 1; i <= (M + 1); i++) {
		p2[i] = 2 * p2[i - 1];
		for (int j = 0; j <= i; j++) {
			if (j == 0 || j == i)
				bc[i][j] = 1;
			else
				bc[i][j] = (bc[i - 1][j - 1] + bc[i - 1][j]);
		}
	}
	for (int i = 0; i <= M; i++) {
		scanf("%lld", &b[i]);
		b[i] %= mod;
	}
	ll J = 1;
	for (int j = 1; j <= M; j++) {
		for (int i = 0; i < N; i++) {
			for (int k = 0; k <= M; k++) {
				if (j == 0 && k == 0) {
					dp[i][k][J] = arr[i];
				} else if (j == 0)
					dp[i][k][J] = 0;
				else {
					dp[i][k][J] = (dp[i][k][1 - J] + dp[i ^ (p2[j - 1])][k - 1][1 - J]);
					if (dp[i][k][J] >= mod)
						dp[i][k][J] -= mod;
				}
			}
		}
		J = 1 - J;
	}

	Matrix B; B.n = 1; B.m = M;

	for (int i = 0; i <= M; i++)
		B.val[0][i] = b[i];

	Matrix c = Pow(B, T);

	ll MD = M % 2, ans;
	for (int i = 0; i < N; i++) {
		ans = 0;
		for (int j = 0; j <= M; j++)
			ans = (ans + (c.val[0][j] * dp[i][j][MD])) % mod;
		printf("%lld\n", ans);
	}
	return 0;
	//This is going to be ACC ^^:)
	//28 wrong answers because of cache xD
}