#include <bits/stdc++.h>
using namespace std;
int n, m, A, Q, mod, f[3000009], fac[3000009];
int ksm(int x, int y, int p) {
  int z = 1;
  for (; y; y >>= 1, x = (long long)x * x % p)
    if (y & 1) z = (long long)z * x % p;
  return z;
}
int main() {
  scanf("%d%d%d%d", &n, &m, &A, &Q);
  int i;
  for (i = A % Q, mod = 1; i != 1; mod++) i = (long long)i * A % Q;
  fac[0] = 1;
  for (i = 1; i < mod; i++) fac[i] = (long long)fac[i - 1] * i % mod;
  f[0] = 1;
  for (i = 1; i <= m; i++) {
    f[i] =
        (f[i - 1] +
         (long long)fac[m] * (((fac[i]) == 0) ? 1 : ksm(fac[i], mod - 2, mod)) %
             mod * (((fac[m - i]) == 0) ? 1 : ksm(fac[m - i], mod - 2, mod))) %
        mod;
  }
  for (i = m + 1; i <= n; i++) f[i] = f[i - 1];
  for (i = n; i; i--) {
    printf("%d%c", ksm(A, f[i - 1], Q), (i > 1) ? ' ' : '\n');
  }
  return 0;
}
