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,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:16777216")
using namespace std;
using matrix = vector<vector<long long>>;
void FAST_IO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
long long phi(long long q) {
  long long res = q;
  for (long long i = 2; i * i <= q; ++i) {
    if (q % i == 0) {
      while (q % i == 0) {
        q /= i;
      }
      res -= res / i;
    }
  }
  if (q != 1) {
    res -= res / q;
  }
  return res;
}
long long binpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n) {
    if (n & 1) {
      res = (res * a) % mod;
    }
    a = (a * a) % mod;
    n >>= 1;
  }
  return res;
}
const int MAXN = 1e6 + 1000;
long long fact[MAXN], invfact[MAXN];
long long sum[MAXN];
long long c(long long n, long long k, long long mod) {
  long long res = fact[n];
  res = (res * invfact[k]) % mod;
  res = (res * invfact[n - k]) % mod;
  return res;
}
long long factmod(long long n, long long p) {
  long long res = 1;
  while (n > 1) {
    res = (res * ((n / p) % 2 ? p - 1 : 1)) % p;
    for (long long i = 2; i <= n % p; ++i) {
      res = (res * i) % p;
    }
    n /= p;
  }
  return res % p;
}
signed main() {
  FAST_IO();
  long long n, m, a, q;
  cin >> n >> m >> a >> q;
  long long p = 1;
  long long cur = a;
  while (cur != 1) {
    cur = (cur * a) % q;
    p++;
  }
  fact[0] = 1;
  invfact[0] = 1;
  for (int i = 1; i < MAXN; ++i) {
    fact[i] = (fact[i - 1] * i) % p;
    invfact[i] = binpow(fact[i], p - 2, p);
  }
  sum[0] = 1;
  for (int i = 1; i <= m; ++i) {
    sum[i] = c(m, i, p);
    sum[i] = (sum[i] + sum[i - 1]) % p;
  }
  for (int i = 0; i < n; ++i) {
    long long cnt = min(n - i - 1, m);
    cout << binpow(a, sum[cnt], q) << ' ';
  }
}
