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 gcd(long long a, long long b, long long &x, long long &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long x1, y1;
  long long ret = gcd(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return ret;
}
long long discreteLog(long long a, long long q) {
  map<long long, long long> mp;
  long long n = 1;
  while (n * n < q) n++;
  long long prd = 1;
  mp[prd] = 0;
  for (int i = 1; i <= n; i++) {
    prd = (prd * a) % q;
    if (prd == 1) return i;
    mp[prd] = i;
  }
  long long inv, tmp;
  gcd(prd, q, inv, tmp);
  prd = inv;
  for (int i = 1; i <= n; i++) {
    if (mp.find(prd) != mp.end()) {
      return n * i + mp[prd];
    }
    prd *= inv;
    prd %= q;
  }
  return -1;
}
const int N = 1111111;
long long fac[N], inv[N], ifac[N];
inline long long modPow(long long a, long long b, long long mod) {
  long long ret = 1;
  while (b) {
    if (b & 1) (ret *= a) %= mod;
    (a *= a) %= mod;
    b >>= 1;
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << setprecision(32);
  int n, m;
  long long q, a;
  cin >> n >> m >> a >> q;
  long long p = discreteLog(a, q);
  fac[0] = ifac[0] = 1;
  fac[1] = ifac[1] = inv[1] = 1;
  for (int i = 2; i <= m; i++) {
    fac[i] = fac[i - 1] * i % p;
    inv[i] = inv[p % i] * (p - (p / i)) % p;
    ifac[i] = ifac[i - 1] * inv[i] % p;
  }
  vector<long long> ans(n);
  for (int i = 0; i < n; i++) {
    if (i > m)
      ans[i] = 0;
    else {
      ans[i] = fac[m] * ifac[i] % p;
      (ans[i] *= ifac[m - i]) %= p;
    }
    if (i != 0) ans[i] += ans[i - 1];
    if (ans[i] >= p) ans[i] -= p;
  }
  reverse(ans.begin(), ans.end());
  for (int i = 0; i < n; i++) {
    cout << modPow(a, ans[i], q) << " ";
  }
  return 0;
}
