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>
using namespace std;
long long pow(long long a, long long b, long long mod, long long r = 1) {
  for (long long i = b; i; i >>= 1, a = (1LL * a * a) % mod)
    if (i & 1) r = (1LL * r * a) % mod;
  return r;
}
struct comb {
  long long n, mod, i;
  vector<long long> F, I;
  comb(long long n, long long mod)
      : n(n),
        mod(mod),
        F(vector<long long>(n + 1, 1)),
        I(vector<long long>(n + 1, 1)) {
    for (i = 1; i <= n; i++) F[i] = (1LL * F[i - 1] * i) % mod;
    i--;
    for (I[n] = pow(F[n], mod - 2, mod); i; i--)
      I[i - 1] = (1LL * I[i] * i) % mod;
  }
  long long nCr(long long n, long long r) {
    return n >= r ? (1LL * F[n] * ((1LL * I[n - r] * I[r]) % mod)) % mod : 0;
  }
};
const long long N = 2e6;
long long coeff[N];
int32_t main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, a, q, p;
  cin >> n >> m >> a >> q;
  for (long long i = 2; true; i++)
    if (pow(a, i, q) == 1) {
      p = i;
      break;
    }
  comb C(m, p);
  for (long long i = 0; i <= m && i < n; i++) {
    long long prv = i ? coeff[i - 1] : 0;
    coeff[i] = (prv + C.nCr(m, i)) % p;
  }
  for (long long i = m + 1; i < n; i++) {
    coeff[i] = pow(2, m, p);
  }
  for (long long i = 1; i <= n; i++) {
    cout << pow(a, coeff[n - i], q) << " \n"[i == n];
  }
}
