Problem: The Elements of Harmony are six supernatural artifacts representing subjective aspects of harmony. They are arguably the most powerful force in Equestria. The inside of Elements of Harmony can be seen as a complete graph with n vertices labeled from 0 to n - 1, where n is a power of two, equal to 2m.

<image>

The energy in Elements of Harmony is in constant movement. According to the ancient book, the energy of vertex u in time i (ei[u]) equals to: 

<image>

Here b[] is the transformation coefficient — an array of m + 1 integers and f(u, v) is the number of ones in the binary representation of number (u xor v).

Given the transformation coefficient and the energy distribution at time 0 (e0[]). Help Twilight Sparkle predict the energy distribution at time t (et[]). The answer can be quite large, so output it modulo p.

Input

The first line contains three integers m, t and p (1 ≤ m ≤ 20; 0 ≤ t ≤ 1018; 2 ≤ p ≤ 109). The following line contains n (n = 2m) integers e0[i] (1 ≤ e0[i] ≤ 109; 0 ≤ i < n). The next line contains m + 1 integers b[i] (0 ≤ b[i] ≤ 109; 0 ≤ i ≤ m).

Output

Output n lines, the i-th line must contain a single integer et[i] modulo p.

Examples

Input

2 2 10000
4 1 2 3
0 1 0


Output

14
6
6
14

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int m, n;
int Num[1050010];
long long t, mod;
long long C[22][22];
long long f[1050010], g[1050010];
long long b[22];
struct Matrix {
  long long a[22][22];
  void clear() { memset(a, 0, sizeof(a)); }
} A, ans;
void pre_C() {
  C[0][0] = 1;
  for (int i = 1; i <= m; ++i) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; ++j) {
      C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
      if (C[i][j] >= mod) C[i][j] -= mod;
    }
  }
  return;
}
long long mul(long long a, long long b) {
  long long s = 0;
  while (b) {
    if (b & 1) {
      s = s + a;
      if (s >= mod) s -= mod;
    }
    a <<= 1;
    if (a >= mod) a -= mod;
    b >>= 1;
  }
  return s;
}
Matrix operator*(const Matrix &A, const Matrix &B) {
  Matrix C;
  C.clear();
  for (int i = 0; i <= m; ++i) {
    for (int j = 0; j <= m; ++j) {
      for (int k = 0; k <= m; ++k) {
        C.a[i][j] = C.a[i][j] + mul(A.a[i][k], B.a[k][j]);
        if (C.a[i][j] >= mod) C.a[i][j] -= mod;
      }
    }
  }
  return C;
}
Matrix pow_mod(Matrix v, long long p) {
  Matrix tmp;
  tmp.clear();
  for (int i = 0; i <= m; ++i) tmp.a[i][i] = 1;
  while (p) {
    if (p & 1) tmp = tmp * v;
    v = v * v;
    p >>= 1;
  }
  return tmp;
}
void FWT(long long *A, int n, int flag) {
  for (int k = 1; k < n; k <<= 1) {
    int mk = (k << 1);
    for (int j = 0; j < n; j += mk) {
      for (int i = 0; i < k; ++i) {
        long long x = A[i + j], y = A[i + j + k];
        A[i + j] = (x + y) >> flag;
        A[i + j + k] = (x - y + mod) >> flag;
        if (A[i + j] >= mod) A[i + j] -= mod;
        if (A[i + j + k] >= mod) A[i + j + k] -= mod;
      }
    }
  }
  return;
}
int main() {
  scanf("%d", &m);
  n = (1 << m);
  scanf("%I64d%I64d", &t, &mod);
  mod *= n;
  pre_C();
  for (int i = 0; i < n; ++i) scanf("%I64d", &f[i]), f[i] %= mod;
  for (int i = 0; i <= m; ++i) scanf("%I64d", &b[i]), b[i] %= mod;
  for (int i = 0; i <= m; ++i) {
    for (int j = 0; j <= m; ++j) {
      int k = i - j;
      for (int x = 0; x <= i; ++x) {
        int y = x - k;
        if (y < 0 || y > m - i) continue;
        int d = x + y;
        A.a[j][i] += mul(b[d], mul(C[i][x], C[m - i][y]));
        if (A.a[j][i] >= mod) A.a[j][i] -= mod;
      }
    }
  }
  A = pow_mod(A, t);
  ans.a[0][0] = 1;
  ans = ans * A;
  for (int i = 0; i < n; ++i) {
    Num[i] = Num[i >> 1] + (i & 1);
    g[i] = ans.a[0][Num[i]];
  }
  FWT(f, n, 0);
  FWT(g, n, 0);
  for (int i = 0; i < n; ++i) f[i] = mul(f[i], g[i]);
  FWT(f, n, 1);
  mod /= n;
  for (int i = 0; i < n; ++i) printf("%I64d\n", f[i] % mod);
  return 0;
}