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 MAXN = 1e5 + 50;
const int LOGN = 30;
const int MAXP = 1e6 + 150;
long long fact[MAXP], powA[MAXP];
long long N, M, a, Q, P;
long long fpow(long long x, long long n) {
  long long t = x;
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = (res * t) % P;
    t = (t * t) % P;
    n /= 2;
  }
  return res;
}
long long inv(long long n, long long p) { return fpow(n, p - 2); }
void findPow() {
  powA[0] = 1;
  for (int i = 1; i < P; i++) powA[i] = (powA[i - 1] * a) % Q;
}
void findFact() {
  fact[0] = 1;
  for (long long x = 1; x <= P - 1; x++) {
    fact[x] = (fact[x - 1] * x) % P;
  }
}
long long f(long long x) {
  long long q = x / Q;
  long long r = x % Q;
  long long res = fact[r];
  if (q & 1) res = P - res;
  return res;
}
int exp(long long x) {
  int res = 0;
  while (x != 0) {
    res += (x / P);
    x /= P;
  }
  return res;
}
long long C(long long n, long long k) {
  if (exp(n) > exp(k) + exp(n - k)) return 0;
  return f(n) * inv(f(k), P) * inv(f(n - k), P);
}
int main() {
  scanf("%lld%lld%lld%lld", &N, &M, &a, &Q);
  long long t = 1;
  for (long long x = 1; x < MAXP; x++) {
    t = (t * a) % Q;
    if (t == 1) {
      P = x;
      break;
    }
  }
  findFact();
  findPow();
  vector<long long> a(N);
  a[0] = 1;
  for (int i = 1; i < N; i++)
    if (i <= M)
      a[i] = (a[i - 1] + C(M, i)) % P;
    else
      a[i] = a[i - 1];
  reverse(a.begin(), a.end());
  for (auto e : a) printf("%lld ", powA[e]);
}
