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;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vpdd = vector<pdd>;
template <typename T>
void ckmin(T &a, const T &b) {
  a = min(a, b);
}
template <typename T>
void ckmax(T &a, const T &b) {
  a = max(a, b);
}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
namespace __input {
template <class T1, class T2>
void re(pair<T1, T2> &p);
template <class T>
void re(vector<T> &a);
template <class T, size_t SZ>
void re(array<T, SZ> &a);
template <class T>
void re(T &x) {
  cin >> x;
}
void re(double &x) {
  string t;
  re(t);
  x = stod(t);
}
template <class Arg, class... Args>
void re(Arg &first, Args &...rest) {
  re(first);
  re(rest...);
}
template <class T1, class T2>
void re(pair<T1, T2> &p) {
  re(p.first, p.second);
}
template <class T>
void re(vector<T> &a) {
  for (int i = 0; i < int((a).size()); i++) re(a[i]);
}
template <class T, size_t SZ>
void re(array<T, SZ> &a) {
  for (int i = 0; i < SZ; i++) re(a[i]);
}
}  // namespace __input
using namespace __input;
namespace __output {
template <typename T>
struct is_outputtable {
  template <typename C>
  static constexpr decltype(declval<ostream &>() << declval<const C &>(),
                            bool())
  test(int) {
    return true;
  }
  template <typename C>
  static constexpr bool test(...) {
    return false;
  }
  static constexpr bool value = test<T>(int());
};
template <
    class T, typename V = decltype(declval<const T &>().begin()),
    typename S = typename enable_if<!is_outputtable<T>::value, bool>::type>
void pr(const T &x);
template <class T,
          typename V = decltype(declval<ostream &>() << declval<const T &>())>
void pr(const T &x) {
  cout << x;
}
template <class T1, class T2>
void pr(const pair<T1, T2> &x);
template <class Arg, class... Args>
void pr(const Arg &first, const Args &...rest) {
  pr(first);
  pr(rest...);
}
template <class T, bool pretty = true>
void prContain(const T &x) {
  if (pretty) pr("{");
  bool fst = 1;
  for (const auto &a : x) pr(!fst ? pretty ? ", " : " " : "", a), fst = 0;
  if (pretty) pr("}");
}
template <class T>
void pc(const T &x) {
  prContain<T, false>(x);
  pr("\n");
}
template <class T1, class T2>
void pr(const pair<T1, T2> &x) {
  pr("{", x.first, ", ", x.second, "}");
}
template <class T, typename V, typename S>
void pr(const T &x) {
  prContain(x);
}
void ps() { pr("\n"); }
template <class Arg>
void ps(const Arg &first) {
  pr(first);
  ps();
}
template <class Arg, class... Args>
void ps(const Arg &first, const Args &...rest) {
  pr(first, " ");
  ps(rest...);
}
}  // namespace __output
using namespace __output;
namespace __algorithm {
template <typename T>
void dedup(vector<T> &v) {
  sort((v).begin(), (v).end());
  v.erase(unique((v).begin(), (v).end()), v.end());
}
template <typename T>
typename vector<T>::const_iterator find(const vector<T> &v, const T &x) {
  auto it = lower_bound((v).begin(), (v).end(), x);
  return it != v.end() && *it == x ? it : v.end();
}
template <typename T>
size_t index(const vector<T> &v, const T &x) {
  auto it = find(v, x);
  assert(it != v.end() && *it == x);
  return it - v.begin();
}
template <typename I>
struct _reversed_struct {
  I &v_;
  explicit _reversed_struct(I &v) : v_{v} {}
  typename I::reverse_iterator begin() const { return v_.rbegin(); }
  typename I::reverse_iterator end() const { return v_.rend(); }
};
template <typename I>
_reversed_struct<I> reversed(I &v) {
  return _reversed_struct<I>(v);
}
}  // namespace __algorithm
using namespace __algorithm;
namespace __io {
void setIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << setprecision(15);
}
}  // namespace __io
using namespace __io;
using v_t = int;
using vv_t = int64_t;
int MOD = 1;
struct modnum {
  v_t v;
  modnum() : v(0) {}
  modnum(vv_t _v) : v(v_t(_v % MOD)) {
    if (v < 0) v += MOD;
  }
  explicit operator v_t() const { return v; }
  friend std::istream &operator>>(std::istream &i, modnum &n) {
    vv_t w;
    i >> w;
    n = modnum(w);
    return i;
  }
  friend std::ostream &operator<<(std::ostream &o, const modnum &n) {
    return o << n.v;
  }
  friend bool operator==(const modnum &a, const modnum &b) {
    return a.v == b.v;
  }
  friend bool operator!=(const modnum &a, const modnum &b) {
    return a.v != b.v;
  }
  friend bool operator<(const modnum &a, const modnum &b) { return a.v < b.v; }
  static unsigned fast_mod(uint64_t x, unsigned m = MOD) {
    return unsigned(x % m);
    unsigned x_high = unsigned(x >> 32), x_low = unsigned(x), quot, rem;
    asm("divl %4\n" : "=a"(quot), "=d"(rem) : "d"(x_high), "a"(x_low), "r"(m));
    return rem;
  }
  modnum &operator+=(const modnum &o) {
    v += o.v;
    if (v >= MOD) v -= MOD;
    return *this;
  }
  modnum &operator-=(const modnum &o) {
    v -= o.v;
    if (v < 0) v += MOD;
    return *this;
  }
  modnum &operator*=(const modnum &o) {
    v = fast_mod(vv_t(v) * o.v);
    return *this;
  }
  modnum operator-() {
    modnum res;
    if (v) res.v = MOD - v;
    return res;
  }
  friend modnum operator+(const modnum &a, const modnum &b) {
    return modnum(a) += b;
  }
  friend modnum operator-(const modnum &a, const modnum &b) {
    return modnum(a) -= b;
  }
  friend modnum operator*(const modnum &a, const modnum &b) {
    return modnum(a) *= b;
  }
  modnum pow(vv_t e) const {
    if (e < 0) return 1 / this->pow(-e);
    if (e == 0) return 1;
    if (e & 1) return *this * this->pow(e - 1);
    return (*this * *this).pow(e / 2);
  }
  modnum inv() const {
    v_t g = MOD, x = 0, y = 1;
    for (v_t r = v; r != 0;) {
      v_t q = g / r;
      g %= r;
      std::swap(g, r);
      x -= q * y;
      std::swap(x, y);
    }
    assert(g == 1);
    assert(y == MOD || y == -MOD);
    return x < 0 ? x + MOD : x;
  }
  modnum &operator/=(const modnum &o) { return (*this) *= o.inv(); }
  friend modnum operator/(const modnum &a, const modnum &b) {
    return modnum(a) /= modnum(b);
  }
  static modnum factorial(int n) {
    static std::vector<modnum> fact = {1};
    assert(n >= 0);
    if (int(fact.size()) <= n) {
      int had = fact.size();
      fact.resize(n + 1);
      for (int i = had; i <= n; i++) fact[i] = fact[i - 1] * i;
    }
    return fact[n];
  }
  static modnum inverse_factorial(int n) {
    static std::vector<modnum> finv = {1};
    assert(n >= 0);
    if (int(finv.size()) <= n) {
      int had = finv.size();
      finv.resize(n + 1), finv[n] = factorial(n).inv();
      for (int i = n - 1; i >= had; i--) finv[i] = finv[i + 1] * (i + 1);
    }
    return finv[n];
  }
  static modnum small_inv(int n) {
    assert(n > 0);
    return factorial(n - 1) * inverse_factorial(n);
  }
  static modnum ncr(int n, int r) {
    if (r < 0 || n < r) return 0;
    return factorial(n) * inverse_factorial(r) * inverse_factorial(n - r);
  }
};
using mn = modnum;
using vmn = vector<mn>;
using vvmn = vector<vmn>;
int main() {
  setIO();
  int n, m, a, q;
  re(n, m, a, q);
  MOD = q;
  int order = 1;
  for (mn prod = a; prod != 1; prod *= a) order++;
  MOD = order;
  vi exponents{1};
  for (int i = 1; i < n; i++)
    exponents.push_back((exponents.back() + mn::ncr(m, i)).v);
  reverse((exponents).begin(), (exponents).end());
  MOD = q;
  vmn ans;
  for (int e : exponents) ans.push_back(mn(a).pow(e));
  pc(ans);
  return 0;
}
