#include <bits/stdc++.h>
using namespace std;
const int M = 21, N = 1100000;
int Mod;
struct Matrix {
  int n, m, A[M][M];
  Matrix(int _n, int _m) {
    n = _n;
    m = _m;
    memset(A, 0, sizeof(A));
  }
  inline Matrix operator*(Matrix &X) {
    Matrix R(n, X.m);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < X.m; j++)
        for (int k = 0; k < m; k++)
          R.A[i][j] = (R.A[i][j] + 1ll * A[i][k] * X.A[k][j]) % Mod;
    return (R);
  }
  inline Matrix operator^(long long pw) {
    Matrix R(n, n), T = *this;
    for (int i = 0; i < n; i++) R.A[i][i] = 1;
    for (; pw; pw >>= 1, T = T * T)
      if (pw & 1) R = R * T;
    return (R);
  }
};
int n, m, B[M], C[M][M], CF[N][M];
long long t;
int main() {
  scanf("%d%lld%d", &m, &t, &Mod);
  n = 1 << m;
  for (int i = 0; i < n; i++) scanf("%d", &CF[i][0]), CF[i][0] %= Mod;
  for (int i = 0; i <= m; i++) scanf("%d", &B[i]);
  for (int i = 0; i < M; i++) {
    C[0][i] = C[i][i] = 1;
    for (int j = 1; j < i; j++) C[j][i] = (C[j][i - 1] + C[j - 1][i - 1]) % Mod;
  }
  Matrix M(m + 1, m + 1);
  for (int i = 0; i <= m; i++)
    for (int j = 0; j <= m; j++)
      for (int k = 0; k <= min(i, j); k++)
        M.A[i][j] = (M.A[i][j] +
                     C[k][j] * 1ll * C[i - k][m - j] % Mod * B[i + j - k - k]) %
                    Mod;
  M = M ^ t;
  for (int pw = 2; pw <= n; pw += pw)
    for (int l = 0; l < n; l += pw)
      for (int i = l; i < l + (pw >> 1); i++)
        for (int j = m; j; j--) {
          int ii = i + (pw >> 1);
          CF[i][j] = (CF[i][j] + CF[ii][j - 1]) % Mod;
          CF[ii][j] = (CF[ii][j] + CF[i][j - 1]) % Mod;
        }
  for (int i = 0; i < n; i++) {
    int tot = 0;
    for (int j = 0; j <= m; j++) tot = (tot + 1ll * CF[i][j] * M.A[0][j]) % Mod;
    printf("%d\n", tot);
  }
  return (0);
}
