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;
const int MAXN = 2000010;
int N;
long long fac[MAXN + 10], afac[MAXN + 10];
long long d[MAXN], mod, bin[MAXN];
int n, m, a;
vector<int> prime;
int is[MAXN];
void GetPrime() {
  prime.clear();
  memset(is, 0, sizeof(is));
  for (int i = 2; i < MAXN; i++) {
    if (is[i] == 0) {
      for (int j = i + i; j < MAXN; j += i) is[j] = 1;
    }
  }
  for (int i = 2; i < MAXN; i++)
    if (is[i] == 0) prime.push_back(i);
}
long long Q_pow(long long x, long long y, long long Mod) {
  long long ret = 1;
  x %= Mod;
  while (y) {
    if (y & 1) ret = ret * x % Mod;
    x = x * x % Mod;
    y >>= 1;
  }
  return ret;
}
void Pre() {
  fac[0] = 1;
  for (int i = 1; i < mod; ++i) fac[i] = fac[i - 1] * (long long)i % mod;
  afac[mod - 1] = Q_pow(fac[mod - 1], mod - 2, mod);
  for (int i = mod - 1; i >= 1; --i) afac[i - 1] = afac[i] * i % mod;
}
long long inv(long long x, long long Mod) { return Q_pow(x, Mod - 2, Mod); }
long long C(long long n, long long m) {
  if (m > n) return 0;
  return fac[n] * afac[n - m] % mod * afac[m] % mod;
}
int main() {
  GetPrime();
  scanf("%d %d %d %I64d", &n, &m, &a, &mod);
  int p = 0;
  for (int i = 0; i < prime.size(); i++) {
    if (Q_pow(a, prime[i], mod) % mod == 1) {
      p = prime[i];
      break;
    }
  }
  long long Mod = mod;
  mod = p;
  Pre();
  memset(d, 0, sizeof(d));
  d[n - 1] = C(m, 0);
  for (int i = n - 2; i >= 0; i--) d[i] = (d[i + 1] + C(m, n - i - 1)) % mod;
  for (int i = 0; i < n; i++) {
    long long tmp = Q_pow(a, d[i] % p, Mod) % Mod;
    printf("%I64d", tmp);
    if (i != n - 1)
      printf(" ");
    else
      printf("\n");
  }
  return 0;
}
