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 n, m, a, q;
const int maxn = 2e6 + 200;
long long f[maxn], invf[maxn];
long long phiq, o;
long long ord(long long n) {
  long long a = ::a, y = a, x = 1;
  while (1) {
    if (y == 1) return x;
    y = y * a % n;
    x++;
  }
  return x;
}
long long mod_pow(long long a, long long k, long long MOD) {
  long long res = 1;
  while (k) {
    if (k & 1) res = res * a % MOD;
    a = a * a % MOD;
    k /= 2;
  }
  return res;
}
long long C(long long n, long long m) {
  if (n < m) return 0;
  return f[n] * invf[m] % o * invf[n - m] % o;
}
long long S[maxn];
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m >> a >> q;
  long long Q = q;
  phiq = q;
  for (long long i = 2; i * i <= Q; i++) {
    if (Q % i == 0) {
      phiq = phiq / i * (i - 1);
      while (Q % i == 0) Q /= i;
    }
  }
  if (Q != 1) phiq = phiq / Q * (Q - 1);
  o = ord(q);
  f[0] = invf[0] = 1;
  for (int i = 1; i < maxn; i++) {
    f[i] = f[i - 1] * i % phiq;
    invf[i] = mod_pow(f[i], o - 2, o);
  }
  for (int i = 1; i <= n; i++) {
    S[i] = (S[i - 1] + C(m, i - 1)) % o;
  }
  for (int i = n; i; i--) {
    cout << mod_pow(a, S[i], q) << " ";
  }
  return 0;
}
