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;
long long n, m, a, q;
long long num[1000500], ans[1000500], fact[1000500];
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
void extgcd(long long a, long long b, long long &x, long long &y) {
  if (b != 0) {
    extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1;
    y = 0;
  }
}
long long mod_inverse(long long a, long long m) {
  long long x, y;
  extgcd(a, m, x, y);
  return (m + x % m) % m;
}
long long mod_fact(long long n, long long p, long long &e) {
  e = 0;
  if (n == 0) return 1;
  long long res = mod_fact(n / p, p, e);
  e += n / p;
  if (n / p % 2 != 0) return res * (p - fact[n % p]) % p;
  return res * fact[n % p] % p;
}
long long mod_comb(long long n, long long k, long long p) {
  if (n < 0 || k < 0 || n < k) return 0;
  long long e1, e2, e3;
  long long a1 = mod_fact(n, p, e1), a2 = mod_fact(k, p, e2),
            a3 = mod_fact(n - k, p, e3);
  if (e1 > e2 + e3) return 0;
  return a1 * mod_inverse(a2 * a3 % p, p) % p;
}
long long phi(long long n) {
  long long rea = n;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) {
      rea = rea - rea / i;
      do n /= i;
      while (n % i == 0);
    }
  if (n > 1) rea = rea - rea / n;
  return rea;
}
long long exp_mod(long long a, long long b, long long c) {
  a %= c;
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % c;
    b >>= 1, a = a * a % c;
  }
  return ans;
}
int main() {
  scanf("%I64d %I64d %I64d %I64d", &n, &m, &a, &q);
  long long p = phi(q), l = (long long)sqrt(p * 1.0), pr = 1e9;
  for (long long i = 1; i <= l; i++)
    if (p % i == 0) {
      if (exp_mod(a, i, q) == 1) pr = min(pr, i);
      if (exp_mod(a, p / i, q) == 1) pr = min(pr, p / i);
    }
  memset(fact, 0, sizeof(fact));
  fact[0] = 1;
  for (int i = 1; i < pr; i++) fact[i] = (fact[i - 1] * i) % pr;
  for (int i = 0; i <= m; i++) num[i] = mod_comb(m, i, pr);
  for (int i = 1; i <= m; i++) num[i] = (num[i] + num[i - 1]) % pr;
  for (int i = 0; i <= m; i++) ans[i] = exp_mod(a, num[i], q);
  for (int i = m + 1; i < n; i++) ans[i] = ans[i - 1];
  for (int i = n - 1; i >= 0; i--) printf("%I64d ", ans[i]);
  return 0;
}
