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;
const int MAXN = 2e6 + 100;
const int MAXM = 22;
int D = 1e9 + 7;
int e[MAXN], b[MAXM];
int m, p;
long long t;
struct Matrix {
  int N = MAXM, M = MAXN;
  vector<int> v[MAXM];
  void cler() {
    for (int i = 0; i < N; i++)
      for (int j = 0; j < M; j++) v[i].push_back(0);
  }
  void set1() {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < M; j++) v[i][j] = 0;
      v[i][i] = 1;
    }
  }
  void pr() {
    cout << '#' << endl;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < M; j++) cout << v[i][j] << ' ';
      cout << endl;
    }
  }
};
Matrix operator*(Matrix A, Matrix B) {
  Matrix Res;
  Res.N = A.N;
  Res.M = B.M;
  Res.cler();
  for (int k = 0; k < A.M; k++)
    for (int i = 0; i < A.N; i++)
      for (int j = 0; j < B.M; j++)
        Res.v[i][j] = (Res.v[i][j] + (1ll * A.v[i][k] * B.v[k][j]) % D) % D;
  return Res;
}
Matrix pw(Matrix A, long long p) {
  Matrix Res;
  Res.N = A.N;
  Res.M = A.M;
  Res.cler();
  Res.set1();
  while (p) {
    if (p & 1) Res = Res * A;
    A = A * A;
    p >>= 1;
  }
  return Res;
}
Matrix dp;
void Cal(int l, int r, int k) {
  if (!k) {
    dp.v[0][l] = e[l] % D;
    return;
  }
  int mid = (l + r) / 2;
  Cal(l, mid, k - 1);
  Cal(mid, r, k - 1);
  int n = (1 << k);
  mid -= l;
  for (int i = 0; i < mid; i++) {
    dp.v[k][l + i] = dp.v[k - 1][l + i + mid];
    dp.v[k][l + i + mid] = dp.v[k - 1][l + i];
  }
  for (int j = k - 1; j >= 1; j--)
    for (int i = 0; i < mid; i++) {
      if (j) {
        dp.v[j][l + i] += dp.v[j - 1][l + i + mid];
        dp.v[j][l + i] %= D;
        dp.v[j][l + i + mid] += dp.v[j - 1][l + i];
        dp.v[j][l + i + mid] %= D;
      }
    }
  return;
}
int F(int x, int y) {
  int p = x ^ y;
  int cnt = 0;
  while (p) {
    int x = (p & -p);
    p -= x;
    cnt++;
  }
  return cnt;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> m >> t >> p;
  dp.N = m + 1;
  dp.M = (1 << m);
  dp.cler();
  D = p;
  for (int i = 0; i < (1 << m); i++) cin >> e[i];
  for (int i = 0; i < m + 1; i++) cin >> b[i];
  int n = (1 << m);
  vector<int> V;
  int tmp = 0;
  for (int i = 0; i < m + 1; i++) {
    V.push_back(tmp);
    tmp *= 2;
    tmp++;
  }
  Matrix A;
  A.N = m + 1;
  A.M = m + 1;
  A.cler();
  for (int i = 0; i < m + 1; i++)
    for (int j = 0; j < n; j++)
      A.v[F(0, j)][i] = (A.v[F(0, j)][i] + b[F(V[i], j)]) % D;
  A = pw(A, t);
  Matrix Res;
  Res.N = 1;
  Res.M = m + 1;
  Res.cler();
  Res.v[0][0] = 1;
  Res = Res * A;
  Cal(0, (1 << m), m);
  for (int i = 0; i < n; i++) {
    long long sum = 0;
    for (int j = 0; j < m + 1; j++)
      sum = (sum + (1ll * dp.v[j][i] * Res.v[0][j]) % p) % p;
    cout << sum << endl;
  }
  return 0;
}