Consider an array A with N elements, all being the same integer a.

Define the product transformation as a simultaneous update Ai = Ai·Ai + 1, that is multiplying each element to the element right to it for <image>, with the last number AN remaining the same. For example, if we start with an array A with a = 2 and N = 4, then after one product transformation A = [4, 4, 4, 2], and after two product transformations A = [16, 16, 8, 2].

Your simple task is to calculate the array A after M product transformations. Since the numbers can get quite big you should output them modulo Q.

Input

The first and only line of input contains four integers N, M, a, Q (7 ≤ Q ≤ 109 + 123, 2 ≤ a ≤ 106 + 123, <image>, <image> is prime), where <image> is the multiplicative order of the integer a modulo Q, see notes for definition.

Output

You should output the array A from left to right.

Example

Input

2 2 2 7


Output

1 2 

Note

The multiplicative order of a number a modulo Q <image>, is the smallest natural number x such that ax mod Q = 1. For example, <image>.
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long N = 2000042;
long long m = 1e9 + 7;
long long n, M, a, q;
long long add(long long x, long long y) { return ((x + y) % m + m) % m; }
long long mul(long long x, long long y) { return ((x * y) % m + m) % m; }
long long binpow(long long x, long long y) {
  long long z = 1;
  while (y) {
    if (y & 1) z = mul(z, x);
    x = mul(x, x);
    y >>= 1;
  }
  return z;
}
long long inv(long long x) { return binpow(x, m - 2); }
long long divide(long long x, long long y) { return mul(x, inv(y)); }
long long fact[N];
void precalc() {
  fact[0] = 1;
  for (long long i = 1; i < N; i++) fact[i] = mul(fact[i - 1], i);
}
long long C(long long n, long long k) {
  if (k > n) return 0;
  return divide(fact[n], mul(fact[k], fact[n - k]));
}
long long A(long long n, long long m) { return divide(fact[n], fact[n - m]); }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> M >> a >> q;
  m = 1;
  long long cur = a % q;
  while (cur != 1) {
    m++;
    cur = (cur * a) % q;
  }
  precalc();
  vector<long long> pows(n, 1);
  for (int i = 1; i < n; i++) pows[i] = add(pows[i - 1], C(M, i));
  reverse((pows).begin(), (pows).end());
  m = q;
  for (int i = 0; i < n; i++) cout << binpow(a, pows[i]) << ' ';
  return 0;
}
