#include <bits/stdc++.h>
using namespace std;
const long long N = 1001001;
long long mod, F[N] = {1}, f[N] = {1}, ans[N] = {0};
long long pmd(long long x, long long p, long long m) {
  long long ans = 1;
  for (; p > 0; p >>= 1) {
    if (p & 1) ans = ans * x % m;
    x = x * x % m;
  }
  return ans;
}
long long inv(long long x, long long m) { return pmd(x, m - 2, m); }
long long C(long long n, long long m) {
  return F[n] * f[m] % mod * f[n - m] % mod;
}
void phi(long long a, long long q) {
  mod = 1;
  for (long long p = a; p != 1; p = p * a % q) mod++;
}
int main() {
  long long n, m, a, q;
  scanf("%lld %lld %lld %lld", &n, &m, &a, &q);
  phi(a, q);
  for (int i = 1; i < N; i++) {
    F[i] = F[i - 1] * i % mod;
    f[i] = f[i - 1] * inv(i, mod) % mod;
  }
  for (int i = 0; i < n; i++) {
    if (i <= m)
      ans[i + 1] = (ans[i] + C(m, i)) % mod;
    else
      ans[i + 1] = ans[i];
  }
  for (int i = 0; i < n; i++)
    printf(i == n - 1 ? "%lld\n" : "%lld ", pmd(a, ans[n - i], q));
}
