#include <bits/stdc++.h>
using namespace std;
const int N = (1 << 20) + 100;
long long P;
int m;
pair<long long, long long> operator*(pair<long long, long long> x,
                                     pair<long long, long long> y) {
  long long a = x.first, b = x.second;
  long long c = y.first, d = y.second;
  long long p = ((a * c % P) << m) % P;
  long long q = b * d;
  long long r = (a * d + b * c) % P;
  return pair<long long, long long>((p + r + (q >> m)) % P, q & ((1 << m) - 1));
}
pair<long long, long long> exp(pair<long long, long long> mul, long long val) {
  pair<long long, long long> ans(0, 1);
  for (; val; val >>= 1) {
    if (val & 1) ans = mul * ans;
    mul = mul * mul;
  }
  return ans;
}
long long calc(pair<long long, long long> x) {
  return (x.first << m) + x.second;
}
pair<long long, long long> calc(long long x) {
  return pair<long long, long long>(x >> m, x & ((1 << m) - 1));
}
long long inc(long long a, long long b) {
  long long c = a + b;
  if (c >= P) c -= P;
  return c;
}
long long dec(long long a, long long b) {
  long long c = a - b;
  if (c < 0) c += P;
  return c;
}
void FWT(long long* x, int l, int r) {
  if (l == r - 1) return;
  FWT(x, l, ((l + r) >> 1));
  FWT(x, ((l + r) >> 1), r);
  long long* y = x + (((l + r) >> 1) - l);
  for (int i = l; i <= ((l + r) >> 1) - 1; i++) x[i] = inc(x[i], y[i]);
  for (int i = l; i <= ((l + r) >> 1) - 1; i++)
    y[i] = dec(x[i], inc(y[i], y[i]));
}
int table[N];
long long val[N], vec[N], ans[N];
int main() {
  long long t;
  cin >> m >> t >> P;
  int n = 1 << m;
  for (int i = 0; i <= n - 1; i++) {
    int x;
    scanf("%d", &x);
    val[i] = x % P;
  }
  for (int i = 0; i <= m; i++) scanf("%d", table + i);
  for (int i = 1; i <= n - 1; i++) vec[i] = vec[i - (i & -i)] + 1;
  for (int i = 0; i <= n - 1; i++) vec[i] = table[vec[i]] % P;
  P <<= m;
  FWT(val, 0, n);
  FWT(vec, 0, n);
  P >>= m;
  for (int i = 0; i <= n - 1; i++)
    ans[i] = calc(calc(val[i]) * exp(calc(vec[i]), t));
  P <<= m;
  FWT(ans, 0, n);
  for (int i = 0; i <= n - 1; i++) {
    int x = ans[i] >> m;
    printf("%d\n", x);
  }
  return 0;
}
