#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e6 + 5;
const int inf = 0x3f3f3f3f;
long long mul(long long a, long long b, long long mod) {
  long long ret = (a * b - (long long)((long double)a * b / mod) * mod);
  if (ret < 0)
    ret += mod;
  else if (ret >= mod)
    ret -= mod;
  return ret;
}
long long qpow(long long base, long long t, long long mod) {
  long long ret = 1;
  while (t) {
    if (t & 1) ret = mul(ret, base, mod);
    base = mul(base, base, mod);
    t >>= 1;
  }
  return ret;
}
long long mod;
void FWT(long long* a, int n, int op) {
  for (int len = 1; len < n; len <<= 1) {
    for (int i = 0; i < n; i += len * 2) {
      for (int j = i; j < i + len; j++) {
        long long x = a[j], y = a[j + len];
        a[j] = (x + y) % mod;
        a[j + len] = (x - y + mod) % mod;
      }
    }
  }
}
long long a[maxn], b[30], e[maxn];
int main(void) {
  int m;
  long long t, p;
  scanf("%d%lld%lld", &m, &t, &p);
  int n = 1 << m;
  mod = (long long)n * p;
  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++) a[i] = b[__builtin_popcount(i)];
  FWT(a, n, 1);
  FWT(e, n, 1);
  for (int i = 0; i < n; i++) {
    a[i] = qpow(a[i], t, mod);
    a[i] = mul(a[i], e[i], mod);
  }
  FWT(a, n, -1);
  for (int i = 0; i < n; i++) printf("%lld\n", (long long)a[i] / n);
}
