#include <bits/stdc++.h>
int M, N;
long long T, MOD, ans[21], bit[21], C[21][21], f[1048576][21];
void MUL(long long *a, long long *b, long long *c) {
  static long long tmp[21];
  for (int i = 0; i <= M; i++) {
    tmp[i] = 0;
    for (int l = 0; l <= i; l++)
      for (int r = 0; r <= M - i; r++)
        tmp[i] = (tmp[i] +
                  C[i][l] * C[M - i][r] % MOD * a[i - l + r] % MOD * b[l + r]) %
                 MOD;
  }
  for (int i = 0; i <= M; i++) c[i] = tmp[i];
}
int main() {
  scanf("%d%lld%lld", &M, &T, &MOD);
  for (int i = 0; i <= M; i++) {
    C[i][0] = 1;
    for (int j = 1; j <= i; j++) C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
  }
  N = 1 << M;
  for (int i = 0; i < N; i++) scanf("%lld", f[i]);
  for (int i = 0; i <= M; i++) {
    ans[i] = i == 0;
    scanf("%lld", bit + i);
  }
  for (; T; T >>= 1) {
    if (T & 1) MUL(ans, bit, ans);
    MUL(bit, bit, bit);
  }
  for (int i = 0, L = 1; i < M; i++, L <<= 1)
    for (int j = 0; j < N; j += L + L)
      for (int k = j; k < j + L; k++)
        for (int l = i; l >= 0; l--) {
          f[k + L][l + 1] = (f[k + L][l + 1] + f[k][l]) % MOD;
          f[k][l + 1] = (f[k][l + 1] + f[k + L][l]) % MOD;
        }
  for (int i = 0; i < N; i++) {
    long long S = 0;
    for (int j = 0; j <= M; j++) S = (S + ans[j] * f[i][j]) % MOD;
    printf("%lld\n", S);
  }
  return 0;
}
