#include <bits/stdc++.h>
using namespace std;
const int M = 21, N = 1 << (M - 1), LOG = 60;
long long n, m, mod, t;
long long dp[N][M], z[M], ans[M], tmp[M];
long long comb[M][M];
void calc(long long *z1, long long *z2) {
  memset(tmp, 0, sizeof tmp);
  for (int k = 0; k <= m; k++) {
    for (int p = 0; p <= m; p++) {
      for (int q = 0; q <= m; q++) {
        int x = p + q - k;
        if (x < 0 || x % 2 == 1) continue;
        x = x / 2;
        if (p - x < 0 || p - x > k || x < 0 || x > m - k) continue;
        long long w = comb[k][p - x] * comb[m - k][x];
        w %= mod;
        w *= z1[p];
        w %= mod;
        w *= z2[q];
        w %= mod;
        tmp[k] += w;
        tmp[k] %= mod;
      }
    }
  }
  for (int i = 0; i <= m; i++) z1[i] = tmp[i];
}
int main() {
  scanf("%I64d %I64d %I64d", &m, &t, &mod);
  n = (1LL << m);
  for (int i = 0; i < n; i++) {
    int k;
    scanf("%d", &k);
    dp[i][0] += k;
    dp[i][0] %= mod;
  }
  for (int i = 0; i <= m; i++) scanf("%d", &z[i]);
  for (int i = 1; i <= m; i++) {
    for (int mask = 0; mask < n; mask++) {
      for (int j = 0; j < m; j++) {
        int m2 = mask ^ (1LL << j);
        dp[mask][i] += dp[m2][i - 1];
      }
      if (i > 1) dp[mask][i] -= (m - i + 2) * dp[mask][i - 2];
      dp[mask][i] /= i;
    }
  }
  for (int i = 0; i <= m; i++)
    for (int mask = 0; mask < n; mask++) dp[mask][i] %= mod;
  if (t == 0) {
    for (int i = 0; i < n; i++) cout << dp[i][0] << ' ';
    cout << '\n';
    return 0;
  }
  for (int i = 0; i <= m; i++) {
    comb[i][0] = comb[i][i] = 1;
    for (int j = 1; j < i; j++)
      comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % mod;
  }
  bool __set = 0;
  for (int j = 0; j < LOG; j++) {
    if (t & (1LL << j)) {
      if (!__set) {
        for (int i = 0; i <= m; i++) ans[i] = z[i];
        __set = 1;
      } else {
        calc(ans, z);
      }
    }
    calc(z, z);
  }
  for (int i = 0; i < n; i++) {
    long long ret = 0;
    for (int j = 0; j <= m; j++) {
      ret += ans[j] * dp[i][j];
      ret %= mod;
    }
    printf("%I64d\n", ret);
  }
}
