#include using namespace std; typedef long long ll; typedef pair P; #define DUMP(x) cout << #x << " = " << (x) << endl; #define FOR(i, m, n) for (ll i = m; i < n; i++) #define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--) #define REP(i, n) FOR(i, 0, n) #define IREP(i, n) IFOR(i, 0, n) #define FOREACH(x, a) for (auto&(x) : (a)) #define ALL(v) (v).begin(), (v).end() #define SZ(x) ll(x.size()) void no() { cout << 0 << endl; exit(0); } ll modpow(ll a, ll b, ll m) { if (b == 0) return 1; ll ret; if (b % 2 == 0) { ll t = modpow(a, b / 2, m) % m; ret = t * t % m; } else { ll t = modpow(a, (b - 1) / 2, m) % m; ret = a * t % m * t % m; } ret %= m; return ret; } /* 二項係数 C(n,k) mod p を計算 */ const int MOD = 1000000007; const int MAX = (1 << 19) + 10; long long fac[MAX], finv[MAX], inv[MAX]; void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } long long COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int main() { ll d, l, r, k; cin >> d >> l >> r >> k; // l,rの深さ(0-indexed)を求める auto depth = [](ll x) { ll res = 0, cur = 2; while (1) { if (x < cur) return res; res++; cur *= 2; } }; ll dl = depth(l), dr = depth(r); // DUMP(dl); // DUMP(dr); if (dl + dr < k) no(); if ((-k + dl + dr) % 2 == 1) no(); ll da = (-k + dl + dr) / 2; // l,rの最近共通祖先の深さ // DUMP(da); if (da > dl) no(); if (dl == dr && dr == da) no(); ll ans; if (dl == 0) { ans = modpow(2, dr, MOD); } else if (dl == dr) { ans = modpow(2, 2 * dl - da - 1, MOD); } else { ans = modpow(2, dr - da, MOD) * ((modpow(2, dl, MOD) - 1 + MOD) % MOD); } COMinit(); REP(i, d) { ll dec = (dl == i) + (dr == i); (ans *= fac[(1 << i) - dec]) %= MOD; } cout << ans << endl; }