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;
int fi(int a) {
  int b = a;
  int fii = 1;
  for (int i = 2; i * i <= b; i++) {
    if (a % i == 0) {
      a /= i;
      fii *= i - 1;
    }
    while (a % i == 0) {
      a /= i;
      fii *= i;
    }
  }
  if (a > 1) return fii * (a - 1);
  return fii;
}
long long pot(long long a, long long w, long long mod) {
  if (w == 0) return 1;
  long long b = pot(a, w / 2, mod);
  b *= b;
  b %= mod;
  if (w % 2 == 1) {
    b *= a;
    b %= mod;
  }
  return b;
}
int rzad(int a, int q) {
  int ord = fi(q);
  int res = ord;
  int morda = ord;
  int orda = ord;
  for (int i = 1; i * i <= orda; i++) {
    if (ord % i == 0) {
      if (pot(a, ord / i, q) == 1) res = min(res, ord / i);
      if (pot(a, i, q) == 1) res = min(res, i);
    }
  }
  return res;
}
const int MAX_N = 1e6 + 200;
long long n, m, a, Q, P;
long long rev(long long a) { return pot(a, P - 2, P); }
long long sil[MAX_N];
long long sym[MAX_N], pref[MAX_N];
int main() {
  scanf("%lld%lld%lld%lld", &n, &m, &a, &Q);
  P = rzad(a, Q);
  sil[0] = 1;
  for (long long i = 1; i < MAX_N; ++i) sil[i] = (sil[i - 1] * i) % P;
  for (long long i = 0; i <= m; ++i) {
    sym[i] = sil[m] * rev(sil[m - i]);
    sym[i] %= P;
    sym[i] *= rev(sil[i]);
    sym[i] %= P;
    if (i != 0) pref[i] = pref[i - 1];
    pref[i] += sym[i];
    pref[i] %= P;
  }
  for (int j = n; j >= 1; --j) {
    printf("%lld ", pot(a, pref[min(m, (long long)j - 1)], Q));
  }
  printf("\n");
  return 0;
}
