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;
template <typename TH>
void _dbg(const char* sdbg, TH h) {
  cerr << sdbg << "=" << h << "\n";
}
template <typename TH, typename... TA>
void _dbg(const char* sdbg, TH h, TA... t) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << "=" << h << ",";
  _dbg(sdbg + 1, t...);
}
template <class C>
void mini(C& a4, C b4) {
  a4 = min(a4, b4);
}
template <class C>
void maxi(C& a4, C b4) {
  a4 = max(a4, b4);
}
template <class T1, class T2>
ostream& operator<<(ostream& out, pair<T1, T2> pair) {
  return out << "(" << pair.first << ", " << pair.second << ")";
}
template <class A, class B, class C>
struct Triple {
  A first;
  B second;
  C third;
  bool operator<(const Triple& t) const {
    if (first != t.first) return first < t.first;
    if (second != t.second) return second < t.second;
    return third < t.third;
  }
};
template <class T>
void ResizeVec(T&, vector<long long>) {}
template <class T>
void ResizeVec(vector<T>& vec, vector<long long> sz) {
  vec.resize(sz[0]);
  sz.erase(sz.begin());
  if (sz.empty()) {
    return;
  }
  for (T& v : vec) {
    ResizeVec(v, sz);
  }
}
template <class A, class B, class C>
ostream& operator<<(ostream& out, Triple<A, B, C> t) {
  return out << "(" << t.first << ", " << t.second << ", " << t.third << ")";
}
template <class T>
ostream& operator<<(ostream& out, vector<T> vec) {
  out << "(";
  for (auto& v : vec) out << v << ", ";
  return out << ")";
}
const long long N = 1e6 + 555;
long long sito[N];
long long spow(long long a, long long b, long long P) {
  long long r = 1;
  while (b) {
    if (b % 2 == 1) {
      r = r * a % P;
    }
    a = a * a % P;
    b /= 2;
  }
  return r;
}
struct FastNewton {
 private:
  long long P;
  long long range;
  vector<long long> inv;
  vector<long long> fact;
  vector<long long> fact_inv;
  vector<long long> v_p;

 public:
  FastNewton(long long _P, long long _range = 0) { init(_P, _range); }
  void init(long long _P, long long _range = -1) {
    P = _P;
    if (_range == -1) {
      range = P;
    } else {
      range = _range;
    }
    inv.resize(range + 5);
    fact.resize(range + 5);
    fact_inv.resize(range + 5);
    v_p.resize(range + 5);
    fact[0] = 1;
    fact_inv[0] = 1;
    inv[0] = -1;
    inv[1] = 1;
    for (long long i = 2; i < min(range, P); i++) {
      inv[i] = P - (P / i) * inv[P % i] % P;
    }
    for (long long i = 1; i <= range; i++) {
      long long tmp = i;
      while (tmp % P == 0) {
        tmp /= P;
      }
      fact[i] = tmp * fact[i - 1] % P;
      fact_inv[i] = fact_inv[i - 1] * inv[tmp % P] % P;
    }
    for (long long i = 1; i <= range; i++) {
      v_p[i] = i / P + v_p[i / P];
    }
  }
  long long get_inv(long long a) const {
    if (a % P == 0) {
      cout << "ERROR: 0 has not got its inverse\n";
      return -1;
    }
    return inv[a % P];
  }
  long long get_normal_fact(long long n) const {
    if (n >= P) {
      return 0;
    }
    return fact[n];
  }
  long long get_better_fact(long long n) const {
    if (n > range) {
      cout << "ERROR: n too large\n";
      return -1;
    }
    return fact[n];
  }
  long long get_v_p(long long n) const {
    if (n > range) {
      cout << "ERROR: n too large\n";
      return -1;
    }
    return v_p[n];
  }
  long long choose(long long n, long long k) const {
    if (k < 0 || k > n) {
      return 0;
    }
    if (v_p[n] == v_p[k] + v_p[n - k]) {
      return fact[n] * fact_inv[k] % P * fact_inv[n - k] % P;
    } else {
      return 0;
    }
  }
};
int32_t main() {
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  if (0) cout << fixed << setprecision(10);
  cin.tie(0);
  long long n, m, a, Q;
  cin >> n >> m >> a >> Q;
  long long fi = Q;
  long long cur_q = Q;
  for (long long i = (2); i <= (N - 1); ++i) {
    if (sito[i] == 0) {
      if (cur_q % i == 0) {
        fi /= i;
        fi *= (i - 1);
        while (cur_q % i == 0) {
          cur_q /= i;
        }
      }
      for (long long j = (2); j <= ((N - 1) / i); ++j) {
        sito[i * j] = 1;
      }
    }
  }
  if (cur_q > 1) {
    fi /= cur_q;
    fi *= (cur_q - 1);
  }
  long long ord = -1;
  long long cur_fi = fi;
  for (long long i = (2); i <= (N - 1); ++i) {
    while (cur_fi % i == 0) {
      cur_fi /= i;
    }
    if (fi % i == 0 && sito[i] == 0) {
      if (spow(a, i, Q) == 1) {
        ord = i;
        break;
      }
    }
  }
  if (ord == -1) {
    ord = cur_fi;
  }
  (ord);
  FastNewton newt(ord, N);
  long long res = 1;
  for (long long i = 0; i < (n + m + 2); ++i) {
    if (i > m || i >= n) {
      break;
    }
    res = res * spow(a, newt.choose(m, i), Q) % Q;
    (m, i, newt.choose(m, i));
  }
  for (long long i = 0; i < (n); ++i) {
    cout << res << " ";
    if (n - 1 - i <= m) {
      (newt.choose(m, n - 1 - i));
      res = res * spow(spow(a, newt.choose(m, n - 1 - i), Q), fi - 1, Q) % Q;
    }
  }
  cout << endl;
  return 0;
}
