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>
struct MI {
 private:
  char bb[4096];
  FILE *f;
  char *bs, *be;
  char e;
  bool o, l;

 public:
  MI() : f(stdin) {}
  inline char get() {
    if (o) {
      o = 0;
      return e;
    }
    if (bs == be) be = (bs = bb) + fread(bb, 1, sizeof(bb), f);
    if (bs == be) {
      l = 1;
      return -1;
    };
    return *bs++;
  }
  inline void unget(char c) {
    o = 1;
    e = c;
  }
  template <typename T>
  inline T read() {
    T r;
    *this > r;
    return r;
  }
  template <typename T>
  inline MI &operator>(T &);
};
template <typename T>
struct Q {
  const static bool U = T(-1) >= T(0);
  inline void operator()(MI &t, T &r) const {
    r = 0;
    char c;
    bool y = 0;
    if (U)
      for (;;) {
        c = t.get();
        if (c == -1) goto E;
        if (isdigit(c)) break;
      }
    else
      for (;;) {
        c = t.get();
        if (c == -1) goto E;
        if (c == '-') {
          c = t.get();
          if (isdigit(c)) {
            y = 1;
            break;
          };
        } else if (isdigit(c))
          break;
        ;
      };
    for (;;) {
      if (c == -1) goto E;
      if (isdigit(c))
        r = r * 10 + (c ^ 48);
      else
        break;
      c = t.get();
    }
    t.unget(c);
  E:;
    if (y) r = -r;
  }
};
template <>
struct Q<char> {};
template <typename T>
inline MI &MI::operator>(T &t) {
  Q<T>()(*this, t);
  return *this;
}
template <typename T>
std::ostream &operator<(std::ostream &out, const T &t) {
  return out << t;
}
using std::cout;
MI cin;
const int $n = 20;
const int $s = 1 << $n;
int n, L, b[$n + 1];
long long K, mod;
long long f[$s], g[$s];
inline long long pro(long long x) { return x >= mod ? x - mod : x; }
inline long long per(long long x) { return x < 0 ? x + mod : x; }
inline long long mul(long long x, long long y) {
  return per(x * y - (unsigned long long)((long double)x / mod * y) * mod);
}
inline long long ksm(long long x, long long p) {
  long long ret = 1;
  for (; p; p >>= 1, x = mul(x, x))
    if (p & 1) ret = mul(ret, x);
  return ret;
}
template <bool rev>
inline void fwt(long long *v) {
  for (int i = 1, q = 2; i < L; q = (i = q) << 1)
    for (int j = 0; j < L; j += q)
      for (int k = 0; k < i; ++k) {
        long long &x = v[j | k], &y = v[i | j | k];
        std::tie(x, y) = std::make_tuple(pro(x + y), per(x - y));
      }
  if (!rev) return;
  for (int i = 0; i < L; ++i) v[i] /= L;
}
int main() {
  cin > n > K > mod;
  mod *= L = 1 << n;
  for (int i = 0; i < L; ++i) f[i] = (cin.read<int>()) % mod;
  for (int i = 0; i <= n; ++i) b[i] = (cin.read<int>()) % mod;
  for (int i = 0; i < L; ++i) g[i] = b[__builtin_popcount(i)];
  fwt<0>(f);
  fwt<0>(g);
  for (int i = 0; i < L; ++i) f[i] = mul(f[i], ksm(g[i], K));
  fwt<1>(f);
  for (int i = 0; i < L; ++i) cout < f[i] < ('\n');
}