#include <bits/stdc++.h>
long long MOD;
long long fmul(long long a, long long b, long long m) {
  return (a * b - (long long)(((long double)a * b + 0.5) / m) * m + m) % m;
}
long long fexp(long long x, long long e) {
  long long ans = 1;
  for (; e > 0; e /= 2) {
    if (e & 1) {
      ans = fmul(x, ans, MOD);
    }
    x = fmul(x, x, MOD);
  }
  return ans;
}
std::vector<long long> FWHT(std::vector<long long> a, bool inv = false) {
  for (int i = 1; i < a.size(); i *= 2) {
    for (int j = 0; j < a.size(); j += 2 * i) {
      for (int k = 0; k < i; k++) {
        long long u = a[j + k];
        long long v = a[j + k + i];
        a[k + j] = (u + v >= MOD ? u + v - MOD : u + v);
        a[k + j + i] = (u + MOD - v >= MOD ? u + MOD - v - MOD : u + MOD - v);
      }
    }
  }
  if (inv) {
    for (int i = 0; i < a.size(); i++) {
      a[i] /= a.size();
    }
  }
  return a;
}
int main() {
  long long m, t;
  std::cin >> m >> t >> MOD;
  int n = 1 << m;
  MOD *= n;
  std::vector<long long> a(n, 0);
  std::vector<long long> b(n, 0);
  std::vector<long long> bb(m + 1, 0);
  std::vector<int> bits(n);
  for (int i = 0; i < n; i++) {
    scanf("%lli", &a[i]);
  }
  for (int i = 0; i <= m; i++) {
    std::cin >> bb[i];
  }
  for (int i = 0; i < n; i++) {
    bits[i] = bits[i / 2] + (i & 1);
    b[i] = bb[bits[i]];
  }
  b = FWHT(b);
  for (int i = 0; i < n; i++) {
    b[i] = fexp(b[i], t);
  }
  a = FWHT(a);
  for (int i = 0; i < n; i++) {
    a[i] = fmul(a[i], b[i], MOD);
  }
  a = FWHT(a, true);
  for (int i = 0; i < n; i++) {
    printf("%lli\n", a[i]);
  }
}
