#include <bits/stdc++.h>
using i64 = long long;
const int N = 2000000 + 7;
i64 n, m, a;
i64 p, q;
i64 fac[N], ifc[N];
i64 x[N];
i64 pow(i64 a, i64 k, i64 p) {
  i64 t = 1;
  for (; k; a = a * a % p, k >>= 1)
    if (k & 1) t = t * a % p;
  return t;
}
int main() {
  scanf("%I64d%I64d%I64d%I64d", &n, &m, &a, &p);
  q = 1;
  for (i64 i = a; i != 1; i = i * a % p, ++q)
    ;
  fac[0] = 1;
  for (int i = 1; i <= m; ++i) fac[i] = fac[i - 1] * i % q;
  ifc[m] = pow(fac[m], q - 2, q);
  for (int i = m - 1; ~i; --i) ifc[i] = ifc[i + 1] * (i + 1) % q;
  for (int i = n; i; --i)
    (x[i] = x[i + 1] +
            (m - n + i >= 0 ? fac[m] * ifc[n - i] % q * ifc[m - n + i] : 0)) %=
        q;
  for (int i = 1; i <= n; ++i) printf("%lld ", pow(a, x[i], p));
  return 0;
}
