#include <bits/stdc++.h>
inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline void sub(long long &a, long long b) {
  a -= b;
  if (a < 0) a += 1000000007;
}
inline void add(long long &a, long long b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
}
template <typename T>
inline T const &MAX(T const &a, T const &b) {
  return a > b ? a : b;
}
template <typename T>
inline T const &MIN(T const &a, T const &b) {
  return a < b ? a : b;
}
inline long long qp(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % 1000000007;
    a = a * a % 1000000007, b >>= 1;
  }
  return ans;
}
inline long long qp(long long a, long long b, long long c) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % c;
    a = a * a % c, b >>= 1;
  }
  return ans;
}
using namespace std;
const unsigned long long ba = 233;
const double eps = 1e-5;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int N = 2000000 + 10, maxn = 1000000 + 10, inf = 0x3f3f3f3f;
map<long long, long long> ma;
long long b[N], f[N], inv[N];
long long n, m, a, q, yg;
inline long long c(int a, int b) {
  if (a < b) return 0;
  return f[a] * inv[b] % yg * inv[a - b] % yg;
}
int main() {
  scanf("%lld%lld%lld%lld", &n, &m, &a, &q);
  for (long long i = 1; i <= 1000123; i++)
    if (qp(a, i, q) == 1) {
      yg = i;
      break;
    }
  f[0] = inv[0] = 1;
  for (int i = 1; i <= m; i++)
    f[i] = f[i - 1] * i % yg, inv[i] = inv[i - 1] * qp(i, yg - 2, yg) % yg;
  for (int i = 1; i <= n; i++)
    b[i] = c(m, i - 1), b[i] = (b[i] + b[i - 1]) % yg;
  reverse(b + 1, b + 1 + n);
  for (int i = 1; i <= n; i++) printf("%lld ", qp(a, b[i], q) % q);
  puts("");
  return 0;
}
