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 = 2e6 + 5;
int n, m;
long long a, Q;
long long p[MAXN];
long long fact[MAXN], invFact[MAXN];
long long fastPow(long long x, long long p, long long mod) {
  long long answer = 1, current = x;
  while (p != 0) {
    if (p % 2 != 0) {
      answer = (answer * current) % mod;
    }
    p /= 2;
    current = (current * current) % mod;
  }
  return answer;
}
long long invValue;
long long inv(long long x, long long mod) { return fastPow(x, mod - 2, mod); }
long long comb(int k, int n, long long mod) {
  if (k < 0) return 0;
  long long answer = 1;
  answer = (answer * fact[n]) % mod;
  answer = (answer * fact[n - k]) % mod;
  answer = (answer * invFact[k]) % mod;
  return answer;
}
void Init() {
  m++;
  long long x = 1;
  for (invValue = 1;; invValue++) {
    x = (x * a) % Q;
    if (x == 1) break;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> a >> Q;
  Init();
  if (n == 1) {
    cout << a % Q << '\n';
    return 0;
  }
  p[0] = 1;
  long long comb = 1;
  for (int i = 2; i <= m; i++) {
    p[0] = (p[0] * 2 - ((i <= n) ? 0 : comb) + invValue) % invValue;
    if (i > n) {
      comb = (comb * ((1LL * (i - 1) * inv(i - n, invValue)) % invValue)) %
             invValue;
    }
  }
  int k = 0;
  comb = 1;
  for (k = 0; k < m - n; k++) {
    comb = (comb * ((1LL * (m - 1 - k) * inv(k + 1, invValue)) % invValue)) %
           invValue;
  }
  if (m - n < 0) {
    k = m - n;
  }
  for (int i = 1; i < n; i++) {
    p[i] = (p[i - 1] - ((k >= 0) ? comb : 0) + invValue) % invValue;
    if (k >= 0) {
      comb = (comb * ((1LL * (m - 1 - k) * inv(k + 1, invValue)) % invValue)) %
             invValue;
    }
    k++;
  }
  for (int i = 0; i < n; i++) {
    cout << fastPow(a, p[i], Q) << " ";
  }
  cout << '\n';
}
