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>
long long n, m, a, q;
std::vector<long long> pq;
long long phi, ord;
long long comb[1000200];
long long S[2];
long long A[1000200];
long long power(long long x, long long r, long long mod) {
  if (r == 0) return 1;
  if (r == 1) return x;
  long long res = power(x, r / 2, mod);
  res = res * res % mod;
  if (r & 1) res = res * x % mod;
  return res;
}
int main() {
  scanf("%I64d%I64d%I64d%I64d", &n, &m, &a, &q);
  a = a % q;
  m++;
  long long tq = q;
  for (long long k = 2; k * k <= tq; k++)
    if (tq % k == 0) {
      pq.push_back(k);
      for (; tq % k == 0;) tq = tq / k;
    }
  if (tq != 1) pq.push_back(tq);
  phi = q;
  for (int i = 0; i < pq.size(); i++) phi = phi / pq[i] * (pq[i] - 1);
  long long tp = phi;
  for (long long k = 2; k * k <= tp; k++)
    if (tp % k == 0) {
      if (power(a, k, q) == (long long)1) {
        ord = k;
        break;
      }
      for (; tp % k == 0;) tp = tp / k;
    }
  if (tp != 1 && ord == 0)
    if (power(a, tp, q) == 1) ord = tp;
  comb[0] = (long long)1;
  for (long long k = 0; k < n; k++) {
    comb[k + 1] = comb[k] * (m - k) % ord;
    comb[k + 1] = comb[k + 1] * power(k + 1, ord - 2, ord) % ord;
  }
  for (long long k = 0; k < n; k++) {
    S[k & 1] = S[k & 1] + comb[k];
    S[k & 1] %= ord;
    A[n - k] = S[k & 1];
  }
  for (long long k = 1; k <= n; k++) printf("%I64d ", power(a, A[k], q));
  printf("\n");
  return 0;
}
