#include <bits/stdc++.h>
using namespace std;
const int N = 4;
typedef int vec[N];
typedef vec mat[N];
mat ma, mb;
vec va, vb;
inline void initmat(mat a) { memset(a, 0, sizeof(mat)); }
inline void unitmat(mat a) {
  initmat(a);
  for (int i = 0; i < N; i++) a[i][i] = 1;
}
inline void copymat(const mat a, mat b) { memcpy(b, a, sizeof(mat)); }
inline void mulmat(const mat a, const mat b, mat c, int mod) {
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++) {
      c[i][j] = 0;
      for (int k = 0; k < N; k++)
        c[i][j] = (c[i][j] + (long long)a[i][k] * b[k][j] % mod) % mod;
    }
}
inline void powmat(const mat a, long long b, mat c, int mod) {
  mat s, t;
  copymat(a, s);
  unitmat(c);
  while (b > 0) {
    if (b & 1) {
      mulmat(c, s, t, mod);
      copymat(t, c);
    }
    mulmat(s, s, t, mod);
    copymat(t, s);
    b >>= 1;
  }
}
inline void mulmatvec(const mat a, const vec b, vec c, int mod) {
  for (int i = 0; i < N; i++) {
    c[i] = 0;
    for (int j = 0; j < N; j++)
      c[i] = (c[i] + (long long)a[i][j] * b[j] % mod) % mod;
  }
}
int main() {
  long long n, k;
  int l, m;
  scanf("%lld%lld%d%d", &n, &k, &l, &m);
  if (m == 1 || (l < 60 && k >= (1LL << l))) {
    puts("0");
    return 0;
  }
  ma[0][0] = 1, ma[0][1] = 1, ma[0][2] = 0, ma[0][3] = 0;
  ma[1][0] = 1, ma[1][1] = 0, ma[1][2] = 0, ma[1][3] = 0;
  ma[2][0] = 0, ma[2][1] = 0, ma[2][2] = 1, ma[2][3] = 1;
  ma[3][0] = 0, ma[3][1] = 1, ma[3][2] = 1, ma[3][3] = 1;
  powmat(ma, n - 1, mb, m);
  va[0] = 1, va[1] = 1, va[2] = 0, va[3] = 0;
  mulmatvec(mb, va, vb, m);
  int x0 = (vb[0] + vb[1]) % m, x1 = (vb[2] + vb[3]) % m;
  int p = 1;
  for (int i = 0; i < l; i++) p = (long long)p * (((k >> i) & 1) ? x1 : x0) % m;
  printf("%d\n", p);
  return 0;
}
