#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const double PI = acos(-1.0);
const double EPS = 1e-8;
inline void II(int &n) {
  char ch = getchar();
  n = 0;
  bool t = 0;
  for (; ch < '0'; ch = getchar())
    if (ch == '-') t = 1;
  for (; ch >= '0'; n = n * 10 + ch - '0', ch = getchar())
    ;
  if (t) n = -n;
}
inline void OO(int a) {
  if (a < 0) {
    putchar('-');
    a = -a;
  }
  if (a >= 10) OO(a / 10);
  putchar(a % 10 + '0');
}
inline int sgn(double x) { return (x > EPS) - (x < -EPS); }
long long fac[1005000], inv[1005000], facinv[1005000], po[1005000],
    invpo[1005000];
int MOD, jie;
inline long long power(long long x, long long y) {
  long long s = 1;
  for (; y; x = x * x % MOD, y >>= 1)
    if (y & 1) s = s * x % MOD;
  return s;
}
void init() {
  fac[0] = fac[1] = inv[0] = inv[1] = facinv[0] = facinv[1] = po[0] = invpo[0] =
      1;
  for (int i = 2; i <= 1000125; ++i) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
    facinv[i] = facinv[i - 1] * inv[i] % MOD;
  }
  for (int i = 1; i <= 1000125; ++i) {
    po[i] = 2 * po[i - 1] % MOD;
    invpo[i] = invpo[i - 1] * inv[2] % MOD;
  }
}
long long C(long long n, long long m) {
  if (n < 0 || m < 0 || m > n) return 0;
  return fac[n] * facinv[m] % MOD * facinv[n - m] % MOD;
}
long long CC(long long n, long long m) {
  if (n < 0 || m < 0 || m > n) return 0;
  long long res = 1;
  for (; n || m; n /= MOD, m /= MOD) res = res * C(n % MOD, m % MOD) % MOD;
  return res;
}
int Euler(int n) {
  int ret = n;
  int lim = sqrt(n + 0.5);
  for (int i = 2; i <= lim; ++i) {
    if (n % i == 0) {
      n /= i;
      ret = ret - ret / i;
    }
    while (n % i == 0) n /= i;
  }
  if (n > 1) ret = ret - ret / n;
  return ret;
}
int n, m, a, q;
int ans[1005000];
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d", &a, &q);
  int phi = Euler(q);
  int lim = sqrt(phi + 0.5);
  jie = 0;
  MOD = q;
  for (int i = 2; i <= lim; ++i) {
    if (phi % i == 0)
      if (power(a, i) == 1) {
        jie = i;
        break;
      }
  }
  if (jie == 0) {
    for (int i = lim; i >= 1; --i) {
      if (phi % i == 0)
        if (power(a, phi / i)) {
          jie = phi / i;
          break;
        }
    }
  }
  MOD = jie;
  init();
  for (int i = 0; i < n; ++i) {
    ans[n - i] = CC(m, i);
  }
  for (int i = n - 1; i >= 1; --i) {
    ans[i] = (ans[i] + ans[i + 1]) % MOD;
  }
  MOD = q;
  for (int i = 1; i <= n; ++i)
    printf("%I64d%c", power(a, ans[i]), i == n ? '\n' : ' ');
  return 0;
}
