#include <bits/stdc++.h>
using namespace std;
long long f[(int)(2e6 + 10)], c[(int)(2e6 + 10)], ans[(int)(2e6 + 10)], i, j, k,
    n, m, a, x, q, q2;
long long fe(long long x, long long y, long long q) {
  if (y == 0) return 1;
  long long t = fe(x, y / 2, q);
  if (y & 1) return t * t % q * x % q;
  return t * t % q;
}
int main() {
  cin >> n >> m >> a >> q;
  x = a;
  for (i = 1; i <= (int)(2e6 + 10); i++) {
    x = x * a % q;
    if (x == 1) break;
  }
  q2 = i + 1;
  f[0] = 1;
  for (i = 1; i <= m; i++) f[i] = f[i - 1] * i % q2;
  for (i = 0; i <= m; i++)
    c[i] = f[m] * fe(f[i], q2 - 2, q2) % q2 * fe(f[m - i], q2 - 2, q2) % q2;
  for (i = 1; i <= n; i++) ans[i] = (c[i - 1] + ans[i - 1]) % q2;
  for (i = 1; i <= n; i++) cout << fe(a, ans[n - i + 1], q) << ' ';
}
