#include <bits/stdc++.h>
using namespace std;
template <class P, class Q>
inline void smin(P &a, Q b) {
  if (b < a) a = b;
}
template <class P, class Q>
inline void smax(P &a, Q b) {
  if (a < b) a = b;
}
const int maxm = 20;
const int maxlg = 63;
int m;
long long t;
int p;
int dp[1 << maxm][maxm + 1];
int odp[1 << maxm][maxm + 1];
int b[maxlg + 5][maxm + 1];
int comb[maxm + 1][maxm + 1];
int ansb[maxm + 1], tmpb[maxm + 1];
void multiply(int A[maxm + 1], int B[maxm + 1], int C[maxm + 1]) {
  memset(C, 0, sizeof ansb);
  for (int i = 0, _n = (int)(m + 1); i < _n; i++)
    for (int j = 0, _n = (int)(m + 1); j < _n; j++)
      for (int k = 0, _n = (int)(m + 1); k < _n; k++)
        if ((i + j + k) % 2 == 0) {
          int overlap = (i + j - k) / 2;
          if (overlap < 0 || overlap > min(i, j) || overlap > m - k) continue;
          C[k] = (C[k] + A[i] * (long long)B[j] % p *
                             (long long)comb[m - k][overlap] % p *
                             (long long)comb[k][i - overlap]) %
                 p;
        }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> m >> t >> p;
  for (int i = 0, _n = (int)(maxm + 1); i < _n; i++) {
    comb[i][0] = comb[i][i] = 1;
    for (int j = (int)(1), _n = (int)(i); j < _n; j++)
      comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % p;
  }
  for (int i = 0, _n = (int)(1 << m); i < _n; i++)
    cin >> dp[i][0], dp[i][0] %= p;
  for (int i = 0, _n = (int)(m + 1); i < _n; i++) cin >> b[0][i], b[0][i] %= p;
  for (int bit = 0, _n = (int)(m); bit < _n; bit++) {
    memcpy(odp, dp, sizeof dp);
    for (int i = 0, _n = (int)(1 << m); i < _n; i++)
      for (int cnt = (int)(bit + 2), _x = (int)(1); cnt-- > _x;) {
        dp[i][cnt] += odp[i ^ (1 << bit)][cnt - 1];
        if (dp[i][cnt] >= p) dp[i][cnt] -= p;
      }
  }
  for (int lg = (int)(1), _n = (int)(maxlg); lg < _n; lg++)
    multiply(b[lg - 1], b[lg - 1], b[lg]);
  ansb[0] = 1;
  for (int lg = 0, _n = (int)(maxlg); lg < _n; lg++)
    if (t >> lg & 1) {
      memcpy(tmpb, ansb, sizeof ansb);
      multiply(tmpb, b[lg], ansb);
    }
  for (int i = 0, _n = (int)(1 << m); i < _n; i++) {
    int res = 0;
    for (int cnt = 0, _n = (int)(m + 1); cnt < _n; cnt++)
      res = (res + ansb[cnt] * (long long)dp[i][cnt]) % p;
    cout << res << endl;
  }
  return 0;
}
