#include <bits/stdc++.h>
using namespace std;
const double PI = acos(0) * 2;
const double EPS = 1e-8;
const long long MOD = 1e9 + 7;
const int MAXN = 1e6 + 5;
const int oo = 1e9;
const double foo = 1e30;
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return __builtin_popcounll(s);
}
template <class T>
T sqr(T x) {
  return x * x;
}
inline void addmod(int& a, int val, int p = MOD) {
  if ((a = (a + val)) >= p) a -= p;
}
inline void submod(int& a, int val, int p = MOD) {
  if ((a = (a - val)) < 0) a += p;
}
inline int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }
long long mod, fact[MAXN], inv[MAXN], ans[MAXN], q, a;
int n, m;
long long power_mod(long long a, long long b, long long mod) {
  long long res = 1;
  while (b) {
    if (b % 2) res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
long long C(int k, int n) {
  if (k > n) return 0;
  return fact[n] * inv[k] % mod * inv[n - k] % mod;
}
int main() {
  cin >> n >> m >> a >> q;
  long long cur = a;
  mod = -1;
  for (int i = 2; i <= 1000123; i++) {
    if (cur == 1) {
      mod = i - 1;
      break;
    }
    cur = cur * a % q;
  }
  fact[0] = inv[0] = 1;
  for (int i = 1; i <= mod; i++)
    fact[i] = fact[i - 1] * i % mod, inv[i] = power_mod(fact[i], mod - 2, mod);
  int gg = min(n - 1, m);
  long long now = 0;
  for (int i = 0; i <= gg; i++) {
    now += C(i, m);
    now %= mod;
    ans[i] = power_mod(a, now, q);
  }
  for (int i = gg + 1; i < n; i++) {
    ans[i] = power_mod(a, now, q);
  }
  for (int i = n - 1; i >= 0; i--) printf("%I64d ", ans[i]);
  return 0;
}
