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;
const int N = (int)1e6 + 7;
const int MOD = (int)1e9 + 7;
const int MAGIC = 200;
int bin(int a, int b, int mod) {
  int res = 1;
  while (b) {
    if (b & 1) res = res * 1ll * a % mod;
    b >>= 1;
    a = a * 1ll * a % mod;
  }
  return res;
}
int phi(int x) {
  int res = x;
  for (int i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      while (x % i == 0) x /= i;
      res -= res / i;
    }
  }
  if (x > 1) res -= res / x;
  return res;
}
int getOrder(int a, int Q) {
  int p = phi(Q);
  int ans = p;
  for (int d = 1; d * d <= p; d++) {
    if (p % d == 0) {
      if (bin(a, d, Q) == 1) ans = min(ans, d);
      if (bin(a, p / d, Q) == 1) ans = min(ans, p / d);
    }
  }
  return ans;
}
int fact[N];
int inv[N];
int cnk(int n, int k, int mod) {
  int res = fact[n];
  res = res * 1ll * bin(fact[k], mod - 2, mod) % mod;
  res = res * 1ll * bin(fact[n - k], mod - 2, mod) % mod;
  return res;
}
int diff[N];
int main() {
  int n, m, a, Q;
  cin >> n >> m >> a >> Q;
  int mod = getOrder(a, Q);
  fact[0] = 1;
  for (int i = 1; i < N; i++) {
    fact[i] = fact[i - 1] * 1ll * i % mod;
  }
  for (int i = 0; i < n; i++) {
    diff[i] = cnk(m, i, mod);
  }
  int sum = 0;
  vector<int> res;
  for (int i = 0; i < n; i++) {
    sum = (sum + diff[i]) % mod;
    res.push_back(bin(a, sum, Q));
  }
  reverse(res.begin(), res.end());
  for (auto it : res) cout << it << ' ';
  return 0;
}
