Consider an array A with N elements, all being the same integer a.

Define the product transformation as a simultaneous update Ai = Ai·Ai + 1, that is multiplying each element to the element right to it for <image>, with the last number AN remaining the same. For example, if we start with an array A with a = 2 and N = 4, then after one product transformation A = [4, 4, 4, 2], and after two product transformations A = [16, 16, 8, 2].

Your simple task is to calculate the array A after M product transformations. Since the numbers can get quite big you should output them modulo Q.

Input

The first and only line of input contains four integers N, M, a, Q (7 ≤ Q ≤ 109 + 123, 2 ≤ a ≤ 106 + 123, <image>, <image> is prime), where <image> is the multiplicative order of the integer a modulo Q, see notes for definition.

Output

You should output the array A from left to right.

Example

Input

2 2 2 7


Output

1 2 

Note

The multiplicative order of a number a modulo Q <image>, is the smallest natural number x such that ax mod Q = 1. For example, <image>.
#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  return a ? gcd(b % a, a) : b;
}
template <typename T>
T lcm(T a, T b) {
  return (a / gcd(a, b)) * b;
}
string int_to_str_easy(long long n) {
  return n ? "" : int_to_str_easy(n / 10) + (char)('0' + n % 10);
}
template <typename T>
bool is_prime_sqrt(T n) {
  if (n == 1) return false;
  T k = trunc(sqrt(n));
  for (T i = 2; i <= k; i++)
    if (n % i == 0) return false;
  return true;
}
bool is_down(char x) { return ('a' <= x && x <= 'z'); }
bool is_upper(char x) { return ('A' <= x && x <= 'Z'); }
bool is_digit(char x) { return ('0' <= x && x <= '9'); }
string follow(string s) {
  for (int i = 0; i < s.length(); i++)
    if (is_upper(s[i])) s[i] += 'a' - 'A';
  return s;
}
const long double pi = 3.141592653589793238462643383279;
const long double log23 = 1.58496250072115618145373894394781;
const long double eps = 1e-8;
const long double zero = 0;
const long long INF = 1e18;
const int COUT = 30;
const int prost = 239;
const long long prost64 = 239;
const int two = 2;
const long long sr = 31;
const long long MOD = 1000000007;
const int BIG = 1e9;
const int alf = 26;
const int MAX_N = 1e6 + 1234;
const int MAX_T = (1 << 20);
const int BLOCK = trunc(sqrt(MAX_N)) + 1;
const int MAX_LOG = 21;
const int km = (1 << 18);
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int bit_max = 32;
const int dig = 10;
const string str_alf = "abcdefghijklmnopqrstuvwxyz";
const string str_alf_big = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
long long power(long long a, long long b, long long m) {
  if (b == 0) return 1;
  long long t = power(a, b >> 1LL, m);
  t = (t * t) % m;
  if (b & 1LL) t = (t * a) % m;
  return t;
}
long long c[MAX_N], pref[MAX_N], m, a, q, kol[MAX_N];
int n;
long long gett(int x) {
  if (x > m) return pref[m];
  return pref[x];
}
long long how(int x, int p) {
  long long ans = 0;
  while (x % p == 0) {
    x /= p;
    ans++;
  }
  return ans;
}
int main() {
  cin.sync_with_stdio(0);
  cin >> n >> m >> a >> q;
  long long phi = 1;
  long long qq = q;
  for (int i = 2; i * i <= q; i++)
    if (qq % i == 0) {
      phi *= (i - 1);
      qq /= i;
      while (qq % i == 0) {
        qq /= i;
        phi *= i;
      }
    }
  if (qq != 1) phi *= qq - 1;
  long long p = phi;
  for (long long i = 1; i * i <= q; i++)
    if (phi % i == 0) {
      if (power(a, i, q) == 1) p = min(p, i);
      long long w = phi / i;
      if (power(a, w, q) == 1) p = min(p, w);
    }
  c[0] = 1;
  kol[0] = 0;
  for (long long t = 1; t <= m; t++) {
    kol[t] = kol[t - 1];
    int a = t;
    while (a % p == 0) {
      kol[t]--;
      a /= p;
    }
    int b = m - t + 1;
    while (b % p == 0) {
      kol[t]++;
      b /= p;
    }
    c[t] = (((c[t - 1] * power(a, p - 2, p)) % p) * b) % p;
  }
  for (int i = 0; i <= m; i++)
    if (kol[i] > 0) c[i] = 0;
  pref[0] = c[0];
  for (int i = 0; i < m; i++) pref[i + 1] = (pref[i] + c[i + 1]) % p;
  for (int i = 0; i < n; i++) cout << power(a, gett(n - i - 1), q) << " ";
  return 0;
}
