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 int binpow(long long int a, long long int n, long long int mod) {
  long long int res = 1;
  while (n) {
    if (n & 1) {
      res = (res * a) % mod;
    }
    a = (a * a) % mod;
    n >>= 1;
  }
  return res;
}
const int KEK = 2e6;
long long int fac[KEK];
long long int inv(long long int a, long long int mod) {
  return binpow(a, mod - 2, mod);
}
long long int phi = 1;
long long int C(long long int a, long long int b) {
  if (b > a) return 0;
  long long int z = fac[a - b] * fac[b] % phi;
  return fac[a] * inv(z, phi) % phi;
}
long long int n, m, a, q;
long long int ans[KEK];
int main() {
  scanf("%lld%lld%lld%lld", &n, &m, &a, &q);
  int cq = q;
  for (long long int i = 2; i * i <= q; i++) {
    if (cq % i != 0) continue;
    long long int pw = 0;
    while (cq % i == 0) {
      pw++;
      cq /= i;
    }
    long long int cp = 1;
    for (auto j = 0; j != pw; j++) cp *= i;
    long long int d = cp - cp / i;
    phi *= d;
  }
  if (cq != 1) phi *= cq - 1;
  long long int ord = phi;
  for (long long int i = 2; i * i <= phi; i++) {
    if (phi % i != 0) continue;
    long long int j = phi / i;
    if (binpow(a, i, q) == 1) ord = min(ord, i);
    if (i != j && binpow(a, j, q) == 1) ord = min(ord, j);
  }
  swap(ord, phi);
  fac[0] = 1;
  for (auto i = 1; i != m + 1; i++) fac[i] = fac[i - 1] * i % phi;
  ans[0] = a % q;
  long long int old = 1;
  for (auto i = 1; i != n; i++) {
    long long int delta = C(m, i);
    old = (old + delta) % phi;
    ans[i] = binpow(a, old, q);
  }
  for (auto i = n - 1; i != -1; i--) printf("%lld ", ans[i]);
}
