#include <bits/stdc++.h>
using namespace std;
int n, m, a, Q, sz, X = 1, inv[1000010], pri[1000010], fac[1000010];
bool ispri[1000010];
long long ans[1000010];
void getinv(int n, int mod) {
  inv[1] = inv[0] = 1;
  fac[1] = fac[0] = 1;
  for (int i = 2; i <= n; i++) {
    fac[i] = (long long)fac[i - 1] * i % mod;
    inv[i] = (long long)(mod - mod / i) * inv[mod % i] % mod;
  }
  for (int i = 1; i <= n; i++) inv[i] = (long long)inv[i] * inv[i - 1] % mod;
}
long long qpow(long long x, long long n, int mod) {
  long long ret = 1;
  while (n) {
    if (n & 1) ret = ret * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return ret;
}
void getprime() {
  memset(ispri, 1, sizeof(ispri));
  ispri[1] = 0;
  for (int i = 2; i < 1000010; i++) {
    if (ispri[i]) pri[++sz] = i;
    for (int j = 1; j <= sz && (long long)i * pri[j] < 1000010; j++) {
      ispri[i * pri[j]] = 0;
      if (i % pri[j] == 0) break;
    }
  }
}
int C(int n, int m, int mod) {
  if (m > n) return 0;
  return (long long)fac[n] * inv[m] % mod * inv[n - m] % mod;
}
int main() {
  getprime();
  scanf("%d%d%d%d", &n, &m, &a, &Q);
  while (qpow(a, pri[X], Q) != 1) X++;
  X = pri[X];
  getinv(m, X);
  for (int i = 1; i <= n; i++) ans[n - i + 1] = ans[n - i + 2] + C(m, i - 1, X);
  for (int i = 1; i < n; i++) printf("%d ", qpow(a, ans[i], Q));
  printf("%d\n", a);
  return 0;
}
