#include <bits/stdc++.h>
using namespace std;
long long MOD, LOGN, MAXN, t;
int T[3][2][2][2] = {{{{1, 1}, {1, -1}}, {{1, 1}, {1, -1}}},
                     {{{0, 1}, {1, 1}}, {{-1, 1}, {1, 0}}},
                     {{{1, 1}, {1, 0}}, {{0, 1}, {1, -1}}}};
long long moo(long long a, long long b) {
  long long x = a * b, y = (long double)a * b / MOD;
  return (x - y * MOD) % MOD;
}
void FFT(vector<long long> &a, int op, bool inverse = false) {
  int u1 = T[op][inverse][0][0], v1 = T[op][inverse][0][1];
  int u2 = T[op][inverse][1][0], v2 = T[op][inverse][1][1];
  for (int b = 0; b < LOGN; b++)
    for (int i = 0; i < MAXN; i++)
      if ((i & (1 << b)) == 0) {
        long long u = a[i], v = a[i + (1 << b)];
        a[i] = (u * u1 + v * v1 + MOD) % MOD;
        a[i + (1 << b)] = (u * u2 + v * v2 + MOD) % MOD;
      }
  if (op == 0 && inverse) {
    for (int i = 0; i < a.size(); i++) a[i] >>= LOGN;
  }
}
long long expo(long long a, long long b) {
  if (b == 0) return 1;
  if (b % 2 == 0) {
    long long middle = expo(a, b / 2);
    return moo(middle, middle);
  } else
    return moo(expo(a, b - 1), a);
}
vector<long long> convolution(vector<long long> a, vector<long long> b,
                              int op) {
  FFT(a, op, false);
  FFT(b, op, false);
  for (int i = 0; i < a.size(); i++) a[i] = moo(a[i], expo(b[i], t));
  FFT(a, op, true);
  return a;
}
vector<long long> a, b, bl;
int main() {
  scanf("%lld %lld %lld", &LOGN, &t, &MOD);
  MAXN = (1 << LOGN);
  MOD <<= LOGN;
  a.assign(MAXN, 0);
  b.assign(LOGN + 1, 0);
  bl.assign(MAXN, 0);
  for (int i = 0; i < MAXN; i++) scanf("%d", &a[i]);
  for (int i = 0; i <= LOGN; i++) scanf("%d", &b[i]);
  for (int i = 0; i < MAXN; i++) {
    bl[i] = b[__builtin_popcount(i)];
  }
  vector<long long> ans = convolution(a, bl, 0);
  for (int i = 0; i < MAXN; i++) {
    printf("%lld\n", ans[i]);
  }
  return 0;
}
