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 calc_mod(long long n, long long mod) {
  long long crt = 1;
  for (long long i = (long long)(0); i < (long long)(1000200); i++) {
    (crt *= n) %= mod;
    if (crt == 1) return i + 1;
  }
  return -1;
}
long long mod_pow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
long long fac[2000010], finv[2000010];
long long comb(long long n, long long r, long long mod) {
  if (n < 0 || r < 0 || n < r)
    return 0;
  else
    return ((fac[n] * finv[n - r]) % mod * finv[r]) % mod;
}
long long N, M, A, Q;
long long p[2000010];
long long mod;
vector<long long> res;
int main() {
  scanf("%lld%lld%lld%lld", &N, &M, &A, &Q);
  mod = calc_mod(A, Q);
  fac[0] = 1;
  for (long long i = (long long)(0); i < (long long)(2000000); i++) {
    fac[i + 1] = fac[i] * (i + 1) % mod;
  }
  for (long long i = (long long)(0); i < (long long)(2000001); i++) {
    finv[i] = mod_pow(fac[i], mod - 2, mod);
  }
  p[N - 1] = 0;
  for (int i = N - 2; i >= 0; i--)
    p[i] = (p[i + 1] + mod_pow(2, N - 1 - i, mod) - 1 + mod) % mod;
  long long crtsum = 0;
  for (int j = N - 1; j >= 0; j--) {
    if (j <= N - 1 - M) {
      res.push_back(mod_pow(2, M, mod));
    } else {
      (crtsum += comb(M, M + j - N + 1, mod)) %= mod;
      res.push_back(crtsum);
    }
  }
  reverse((res).begin(), (res).end());
  for (long long j = (long long)(0); j < (long long)(N); j++) {
    cout << mod_pow(A, res[j], Q) << " ";
  }
  cout << endl;
  return 0;
}
