#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFLL = 0x3f3f3f3f3f3f3f3fLL;
const int MX = 1e6 + 200;
int n, m, mod, mod2;
long long a;
void pre_solve() {
  long long inv = 1;
  mod2 = 1;
  while (a * inv % mod != 1) {
    inv = inv * a % mod;
    mod2++;
  }
}
long long F[MX], invF[MX];
long long power(long long a, long long b, int md) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = (ret * a) % md;
    a = (a * a) % md;
    b >>= 1;
  }
  return ret;
}
void init() {
  F[0] = 1;
  for (int i = 1; i < MX; i++) {
    F[i] = (F[i - 1] * i) % mod2;
    invF[i] = power(F[i], mod2 - 2, mod2);
  }
}
long long C(int n, int m) {
  if (n < 0 || m < 0 || m > n) return 0;
  if (m == 0 || m == n) return 1;
  return F[n] * invF[n - m] % mod2 * invF[m] % mod2;
}
long long ans[MX];
int main() {
  cin >> n >> m >> a >> mod;
  pre_solve();
  init();
  long long pw = 0;
  for (int i = n + 1 - 1; i >= (1); --i) {
    pw = (pw + C(m, n - i)) % mod2;
    ans[i] = power(a, pw, mod);
  }
  for (int i = 1; i < (n + 1); ++i) printf("%lld ", ans[i]);
  return 0;
}
