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;
void(o_o)();
long long int i, j, k;
const long long int mod = 1000000007;
const long long int inf = 0x3f3f3f3f3f3f3f3fLL;
int main() {
  cout << fixed << setprecision(10);
  int t = 1;
  while (t--) (o_o)();
}
long long int fact[1000500];
inline long long int power(long long int x, long long int n,
                           long long int m = LLONG_MAX) {
  long long int res = 1;
  x = (x % m + m) % m;
  while (n) {
    if (n & 1) res = (res * x) % m;
    x = (x * x) % m;
    n >>= 1;
  }
  return res;
}
long long int ncr(long long int n, long long int r, long long int Q) {
  if (n < r || r < 0 || n < 0) return 0;
  if (n == r || r == 0) return 1;
  long long int p = fact[n];
  p *= power(fact[r], Q - 2, Q);
  p %= Q;
  p *= power(fact[n - r], Q - 2, Q);
  p %= Q;
  return p;
}
void(o_o)() {
  long long int n, m, a, q;
  cin >> n >> m >> a >> q;
  long long int Q = 1, cur = a;
  while (cur != 1) {
    Q++;
    cur *= a;
    cur %= q;
  }
  vector<long long int> v;
  long long int sum = 0;
  fact[0] = 1;
  for (i = 1; i < 1000500; i++) fact[i] = (i * fact[i - 1]) % Q;
  for (i = n; i >= 1; i--) {
    sum += ncr(m, n - i, Q);
    sum %= Q;
    v.emplace_back(sum);
  }
  reverse(v.begin(), v.end());
  for (long long int it : v) cout << power(a, it, q) << " ";
  cout << endl;
}
