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;
int n, m, a, Q, sz, X = 1, inv[1000010], pri[1000010], fac[1000010];
bool ispri[1000010];
long long ans[1000010];
void getinv(int n, int mod) {
  inv[1] = inv[0] = 1;
  fac[1] = fac[0] = 1;
  for (int i = 2; i <= n; i++) {
    fac[i] = (long long)fac[i - 1] * i % mod;
    inv[i] = (long long)(mod - mod / i) * inv[mod % i] % mod;
  }
  for (int i = 1; i <= n; i++) inv[i] = (long long)inv[i] * inv[i - 1] % mod;
}
long long qpow(long long x, long long n, int mod) {
  long long ret = 1;
  while (n) {
    if (n & 1) ret = ret * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return ret;
}
void getprime() {
  memset(ispri, 1, sizeof(ispri));
  ispri[1] = 0;
  for (int i = 2; i < 1000010; i++) {
    if (ispri[i]) pri[++sz] = i;
    for (int j = 1; j <= sz && (long long)i * pri[j] < 1000010; j++) {
      ispri[i * pri[j]] = 0;
      if (i % pri[j] == 0) break;
    }
  }
}
int C(int n, int m, int mod) {
  if (m > n) return 0;
  return (long long)fac[n] * inv[m] % mod * inv[n - m] % mod;
}
int main() {
  getprime();
  scanf("%d%d%d%d", &n, &m, &a, &Q);
  while (qpow(a, pri[X], Q) != 1) X++;
  X = pri[X];
  getinv(m, X);
  for (int i = 1; i <= n; i++) ans[n - i + 1] = ans[n - i + 2] + C(m, i - 1, X);
  for (int i = 1; i < n; i++) printf("%d ", qpow(a, ans[i], Q));
  printf("%d\n", a);
  return 0;
}
