#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 200, D = 12;
int n, m, a, q, mod;
long long fac[N], inv[N], sum[N];
long long bp(long long a, long long p, long long mod) {
  long long r = 1;
  while (p > 0) {
    if (p & 1) r = r * a % mod;
    p >>= 1;
    a = a * a % mod;
  }
  return r;
}
long long c(int n, int k) { return fac[n] * inv[n - k] % mod * inv[k] % mod; }
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> a >> q;
  long long x = 1;
  for (int i = 1; i < N; i++) {
    x = x * a % q;
    if (x == 1) {
      mod = i;
      break;
    }
  }
  fac[0] = inv[0] = 1;
  for (int i = 1; i < N; i++) {
    fac[i] = fac[i - 1] * i % mod;
    inv[i] = bp(fac[i], mod - 2, mod);
  }
  sum[0] = 1;
  for (int i = 1; i <= m; i++) {
    sum[i] = (sum[i - 1] + c(m, i)) % mod;
  }
  for (int i = 0; i < n; i++) {
    cout << bp(a, sum[min(m + 1, n - i) - 1], q) << " ";
  }
  return 0;
}
