#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios {
  fast_ios() {
    cin.tie(nullptr), ios::sync_with_stdio(false),
        cout << fixed << setprecision(20);
  };
} fast_ios_;
template <typename T, typename V>
void ndarray(vector<T> &vec, const V &val, int len) {
  vec.assign(len, val);
}
template <typename T, typename V, typename... Args>
void ndarray(vector<T> &vec, const V &val, int len, Args... args) {
  vec.resize(len),
      for_each(begin(vec), end(vec), [&](T &v) { ndarray(v, val, args...); });
}
template <typename T>
bool chmax(T &m, const T q) {
  if (m < q) {
    m = q;
    return true;
  } else
    return false;
}
template <typename T>
bool chmin(T &m, const T q) {
  if (m > q) {
    m = q;
    return true;
  } else
    return false;
}
int floor_lg(long long x) { return x <= 0 ? -1 : 63 - __builtin_clzll(x); }
template <typename T1, typename T2>
pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) {
  return make_pair(l.first + r.first, l.second + r.second);
}
template <typename T1, typename T2>
pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) {
  return make_pair(l.first - r.first, l.second - r.second);
}
template <typename T>
vector<T> sort_unique(vector<T> vec) {
  sort(vec.begin(), vec.end()),
      vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << '[';
  for (auto v : vec) os << v << ',';
  os << ']';
  return os;
}
template <typename T, size_t sz>
ostream &operator<<(ostream &os, const array<T, sz> &arr) {
  os << '[';
  for (auto v : arr) os << v << ',';
  os << ']';
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const deque<T> &vec) {
  os << "deq[";
  for (auto v : vec) os << v << ',';
  os << ']';
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &vec) {
  os << '{';
  for (auto v : vec) os << v << ',';
  os << '}';
  return os;
}
template <typename T, typename TH>
ostream &operator<<(ostream &os, const unordered_set<T, TH> &vec) {
  os << '{';
  for (auto v : vec) os << v << ',';
  os << '}';
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &vec) {
  os << '{';
  for (auto v : vec) os << v << ',';
  os << '}';
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &vec) {
  os << '{';
  for (auto v : vec) os << v << ',';
  os << '}';
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &pa) {
  os << '(' << pa.first << ',' << pa.second << ')';
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const map<TK, TV> &mp) {
  os << '{';
  for (auto v : mp) os << v.first << "=>" << v.second << ',';
  os << '}';
  return os;
}
template <typename TK, typename TV, typename TH>
ostream &operator<<(ostream &os, const unordered_map<TK, TV, TH> &mp) {
  os << '{';
  for (auto v : mp) os << v.first << "=>" << v.second << ',';
  os << '}';
  return os;
}
template <typename T, typename F>
void abstract_fwht(std::vector<T> &seq, F f) {
  const int n = seq.size();
  assert(__builtin_popcount(n) == 1);
  for (int w = 1; w < n; w *= 2) {
    for (int i = 0; i < n; i += w * 2) {
      for (int j = 0; j < w; j++) {
        f(seq[i + j], seq[i + j + w]);
      }
    }
  }
}
lint power(__int128 x, lint n, lint MOD) {
  x %= MOD;
  __int128 ans = 1;
  while (n) {
    if (n & 1) (ans *= x) %= MOD;
    (x *= x) %= MOD;
    n >>= 1;
  }
  return ans;
}
int main() {
  int M;
  lint T_, P;
  cin >> M >> T_ >> P;
  vector<lint> e(1 << M), b(M + 1);
  cin >> e >> b;
  vector<lint> trans(1 << M), tmp(1 << M);
  for (int s = (0), s_end_ = (trans.size()); s < s_end_; s++)
    trans[s] = b[__builtin_popcount(s)] % P;
  lint md = P << M;
  using T = lint;
  auto f = [&md](T &lo, T &hi) {
    T c = lo + hi;
    hi = lo - hi, lo = c;
    if (hi < 0) hi += md;
    if (lo >= md) lo -= md;
  };
  abstract_fwht(trans, f);
  vector<__int128> cnt2v(M + 1, -1);
  for (int i = (0), i_end_ = (trans.size()); i < i_end_; i++) {
    auto x = trans[i];
    int pc = __builtin_popcount(i);
    if (cnt2v[pc] >= 0)
      trans[i] = cnt2v[pc];
    else
      trans[i] = cnt2v[pc] = power(x, T_, P << M);
  }
  abstract_fwht(e, f);
  for (int i = (0), i_end_ = (e.size()); i < i_end_; i++)
    e[i] = (__int128(e[i]) * trans[i]) % (P << M);
  abstract_fwht(e, f);
  for (auto x : e) cout << ((x >> M) % P + P) % P << '\n';
}

### Prompt

In CPP, your task is to solve the following 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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios {
  fast_ios() {
    cin.tie(nullptr), ios::sync_with_stdio(false),
        cout << fixed << setprecision(20);
  };
} fast_ios_;
template <typename T, typename V>
void ndarray(vector<T> &vec, const V &val, int len) {
  vec.assign(len, val);
}
template <typename T, typename V, typename... Args>
void ndarray(vector<T> &vec, const V &val, int len, Args... args) {
  vec.resize(len),
      for_each(begin(vec), end(vec), [&](T &v) { ndarray(v, val, args...); });
}
template <typename T>
bool chmax(T &m, const T q) {
  if (m < q) {
    m = q;
    return true;
  } else
    return false;
}
template <typename T>
bool chmin(T &m, const T q) {
  if (m > q) {
    m = q;
    return true;
  } else
    return false;
}
int floor_lg(long long x) { return x <= 0 ? -1 : 63 - __builtin_clzll(x); }
template <typename T1, typename T2>
pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) {
  return make_pair(l.first + r.first, l.second + r.second);
}
template <typename T1, typename T2>
pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) {
  return make_pair(l.first - r.first, l.second - r.second);
}
template <typename T>
vector<T> sort_unique(vector<T> vec) {
  sort(vec.begin(), vec.end()),
      vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << '[';
  for (auto v : vec) os << v << ',';
  os << ']';
  return os;
}
template <typename T, size_t sz>
ostream &operator<<(ostream &os, const array<T, sz> &arr) {
  os << '[';
  for (auto v : arr) os << v << ',';
  os << ']';
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const deque<T> &vec) {
  os << "deq[";
  for (auto v : vec) os << v << ',';
  os << ']';
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &vec) {
  os << '{';
  for (auto v : vec) os << v << ',';
  os << '}';
  return os;
}
template <typename T, typename TH>
ostream &operator<<(ostream &os, const unordered_set<T, TH> &vec) {
  os << '{';
  for (auto v : vec) os << v << ',';
  os << '}';
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &vec) {
  os << '{';
  for (auto v : vec) os << v << ',';
  os << '}';
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &vec) {
  os << '{';
  for (auto v : vec) os << v << ',';
  os << '}';
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &pa) {
  os << '(' << pa.first << ',' << pa.second << ')';
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const map<TK, TV> &mp) {
  os << '{';
  for (auto v : mp) os << v.first << "=>" << v.second << ',';
  os << '}';
  return os;
}
template <typename TK, typename TV, typename TH>
ostream &operator<<(ostream &os, const unordered_map<TK, TV, TH> &mp) {
  os << '{';
  for (auto v : mp) os << v.first << "=>" << v.second << ',';
  os << '}';
  return os;
}
template <typename T, typename F>
void abstract_fwht(std::vector<T> &seq, F f) {
  const int n = seq.size();
  assert(__builtin_popcount(n) == 1);
  for (int w = 1; w < n; w *= 2) {
    for (int i = 0; i < n; i += w * 2) {
      for (int j = 0; j < w; j++) {
        f(seq[i + j], seq[i + j + w]);
      }
    }
  }
}
lint power(__int128 x, lint n, lint MOD) {
  x %= MOD;
  __int128 ans = 1;
  while (n) {
    if (n & 1) (ans *= x) %= MOD;
    (x *= x) %= MOD;
    n >>= 1;
  }
  return ans;
}
int main() {
  int M;
  lint T_, P;
  cin >> M >> T_ >> P;
  vector<lint> e(1 << M), b(M + 1);
  cin >> e >> b;
  vector<lint> trans(1 << M), tmp(1 << M);
  for (int s = (0), s_end_ = (trans.size()); s < s_end_; s++)
    trans[s] = b[__builtin_popcount(s)] % P;
  lint md = P << M;
  using T = lint;
  auto f = [&md](T &lo, T &hi) {
    T c = lo + hi;
    hi = lo - hi, lo = c;
    if (hi < 0) hi += md;
    if (lo >= md) lo -= md;
  };
  abstract_fwht(trans, f);
  vector<__int128> cnt2v(M + 1, -1);
  for (int i = (0), i_end_ = (trans.size()); i < i_end_; i++) {
    auto x = trans[i];
    int pc = __builtin_popcount(i);
    if (cnt2v[pc] >= 0)
      trans[i] = cnt2v[pc];
    else
      trans[i] = cnt2v[pc] = power(x, T_, P << M);
  }
  abstract_fwht(e, f);
  for (int i = (0), i_end_ = (e.size()); i < i_end_; i++)
    e[i] = (__int128(e[i]) * trans[i]) % (P << M);
  abstract_fwht(e, f);
  for (auto x : e) cout << ((x >> M) % P + P) % P << '\n';
}

```