#include <bits/stdc++.h>
using namespace std;
const int Maxm = 21;
const int Maxn = 1 << 20;
int Mod, n, m;
long long t;
long long adj[Maxm * 10][Maxm * 10];
long long cur[Maxm * 10];
long long C[Maxm * 10][Maxm * 10];
int init[Maxn];
int dp[Maxn][Maxm];
int c[Maxm * 10];
void mul(long long a[Maxm * 10], long long b[Maxm * 10]) {
  memset(c, 0, sizeof c);
  for (int dif = 0; dif <= m; dif++) {
    for (int both = 0; both <= m - dif; both++) {
      for (int same = 0; same <= dif; same++) {
        int not_same = dif - same;
        if (m - dif - both + not_same < 0 || m - dif - both + same < 0)
          continue;
        long long cnt = ((((C[m - dif][both] * C[dif][same]) % Mod) *
                          a[m - dif - both + not_same]) %
                         Mod) *
                        b[m - dif - both + same];
        c[dif] += cnt % Mod;
        c[dif] %= Mod;
      }
    }
  }
  return;
}
int main() {
  cin >> m >> t >> Mod;
  n = 1 << m;
  for (int i = 0; i < Maxm * 10; i++)
    for (int j = 0; j <= i; j++)
      if (i == j || !j)
        C[i][j] = 1;
      else
        C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % Mod;
  for (int i = 0; i < n; i++) scanf("%d", &init[i]);
  for (int i = 0; i <= m; i++) cin >> adj[0][i];
  for (int lv = 1; lv <= 60; lv++) {
    mul(adj[lv - 1], adj[lv - 1]);
    for (int i = 0; i <= m; i++) adj[lv][i] = c[i];
  }
  cur[0] = 1;
  for (int bit = 0; bit <= 60; bit++) {
    if ((1LL << bit) & t) {
      mul(cur, adj[bit]);
      for (int i = 0; i <= m; i++) cur[i] = c[i];
    }
  }
  for (int i = 0; i < n; i++) dp[i][0] = init[i] % Mod;
  for (int lb = 0; lb < m; lb++) {
    for (int diff = lb + 1; diff; diff--) {
      for (int mask = 0; mask < n; mask++) {
        dp[mask][diff] =
            (dp[mask][diff] + dp[mask ^ (1 << lb)][diff - 1]) % Mod;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    long long ans = 0;
    for (int j = 0; j <= m; j++) ans += ((cur[j] * dp[i][j]) % Mod), ans %= Mod;
    printf("%d\n", ans);
  }
  return 0;
}
