#include <bits/stdc++.h>
const int N = 2e6 + 5;
using namespace std;
long long mod, t;
int m, n, p;
inline long long moc(long long a) {
  if (a >= mod) return a - mod;
  return a;
}
inline long long fix(const long long a) { return moc(a % mod + mod); }
void fwtxor(long long *a, int lim, bool type) {
  for (register int k = 1; k < lim; k <<= 1) {
    for (register int j = 0; j < lim; j += k << 1) {
      for (register int i = 0; i < k; i++) {
        register long long u = a[i + j], v = a[i + j + k];
        a[i + j] = moc(u + v);
        a[i + j + k] = moc(u - v + mod);
      }
    }
  }
  if (type) return;
  for (register int i = 0; i < lim; i++) a[i] = a[i] / lim;
}
inline long long mul(long long a, long long b) {
  return fix(a * b - (long long)((long double)a / mod * b) * mod);
}
long long e[N], B[N], b[30];
int bitcnt[N];
int main() {
  cin >> m >> t >> p;
  n = (1 << m);
  mod = 1ll * p * n;
  for (int i = 0; i < n; i++) scanf("%lld", &e[i]), e[i] %= mod;
  for (int i = 0; i <= m; i++) scanf("%lld", &b[i]), b[i] %= mod;
  for (int i = 0; i < n; i++) {
    if (i) bitcnt[i] = bitcnt[i ^ (i & -i)] + 1;
    B[i] = b[bitcnt[i]];
  }
  fwtxor(e, n, 1);
  fwtxor(B, n, 1);
  for (; t; t >>= 1) {
    if (t & 1)
      for (int i = 0; i < n; i++) e[i] = mul(e[i], B[i]);
    for (int i = 0; i < n; i++) B[i] = mul(B[i], B[i]);
  }
  fwtxor(e, n, 0);
  for (int i = 0; i < n; i++) {
    printf("%lld\n", e[i]);
  }
  return 0;
}
