#include <bits/stdc++.h>
using namespace std;
const int MAXM = 21, MAXN = 1e6 + 5e4, MAXL = 61;
long long dp[MAXL][MAXM], choose[MAXM + 10][MAXM + 10], ans[MAXM], ans2[MAXM];
int sum[MAXN][MAXM];
int main() {
  int n, p;
  long long T;
  scanf("%d %I64d %d", &n, &T, &p);
  for (int i = 0, x; i < (1 << n); i++) {
    scanf("%d", &x);
    sum[i][0] = x % p;
  }
  for (int i = 0, x; i <= n; i++) {
    scanf("%d", &x);
    dp[0][i] = x % p;
  }
  for (int i = 0; i <= n + 5; i++) choose[0][i] = 1;
  for (int i = 1; i <= n + 5; i++)
    for (int j = 1; j <= i; j++)
      choose[j][i] = (choose[j][i - 1] + choose[j - 1][i - 1]) % p;
  for (int i = 0; i < n; i++)
    for (int t = n; t > 0; t--)
      for (int j = 0; j < (1 << n); j++)
        sum[j][t] = (sum[j][t] + sum[j ^ (1 << i)][t - 1]) % p;
  for (int i = 1; i < MAXL; i++) {
    for (int d = 0; d <= n; d++) {
      for (int j = 0; j <= n; j++) {
        for (int t = 0; t <= n; t++) {
          int a = (d + j - t);
          if (a < 0 or a & 1) continue;
          a /= 2;
          if (a > d) continue;
          if (j - a > n - d or j - a < 0) continue;
          long long aux = (dp[i - 1][j] * dp[i - 1][t]) % p;
          aux = (aux * choose[a][d]) % p;
          aux = (aux * choose[j - a][n - d]) % p;
          dp[i][d] = (dp[i][d] + aux) % p;
        }
      }
    }
  }
  int MAXB;
  for (int i = 0; i < MAXL; i++)
    if (T & (1ll << i)) MAXB = i;
  for (int i = 0; i <= n; i++) ans[i] = dp[MAXB][i];
  for (int i = MAXB - 1; i > -1; i--) {
    if (T & (1ll << i)) {
      memset(ans2, 0, sizeof ans2);
      for (int d = 0; d <= n; d++) {
        for (int j = 0; j <= n; j++) {
          for (int t = 0; t <= n; t++) {
            int a = (d + j - t);
            if (a < 0 or a & 1) continue;
            a /= 2;
            if (a > d) continue;
            if (j - a > n - d or j - a < 0) continue;
            long long aux = (ans[j] * dp[i][t]) % p;
            aux = (aux * choose[a][d]) % p;
            aux = (aux * choose[j - a][n - d]) % p;
            ans2[d] = (ans2[d] + aux) % p;
          }
        }
      }
      for (int j = 0; j <= n; j++) ans[j] = ans2[j];
    }
  }
  for (int i = 0; i < (1 << n); i++) {
    int ret = 0;
    for (int j = 0; j <= n; j++)
      ret = ((long long)ret + 1ll * sum[i][j] * ans[j]) % p;
    printf("%d\n", ret);
  }
  return 0;
}
