//#define _GLIBCXX_DEBUG #include "bits/stdc++.h" using namespace std; //------------------------------- Libraries --------------------------------// template struct Modint { int value; Modint() : value(0) {} Modint(long x) : value(x >= 0 ? x % p : (p + x % p) % p) {} inline Modint &operator+=(const Modint &b) { if ((this->value += b.value) >= p) this->value -= p; return (*this); } inline Modint &operator-=(const Modint &b) { if ((this->value += p - b.value) >= p) this->value -= p; return (*this); } inline Modint &operator*=(const Modint &b) { this->value = (int)((1LL * this->value * b.value) % p); return (*this); } inline Modint &operator/=(const Modint &b) { (*this) *= b.inverse(); return (*this); } Modint operator+(const Modint &b) const { return Modint(*this) += b; } Modint operator-(const Modint &b) const { return Modint(*this) -= b; } Modint operator*(const Modint &b) const { return Modint(*this) *= b; } Modint operator/(const Modint &b) const { return Modint(*this) /= b; } inline Modint &operator++(int) { return (*this) += 1; } inline Modint &operator--(int) { return (*this) -= 1; } inline bool operator==(const Modint &b) const { return this->value == b.value; } inline bool operator!=(const Modint &b) const { return this->value != b.value; } inline bool operator<(const Modint &b) const { return this->value < b.value; } inline bool operator<=(const Modint &b) const { return this->value <= b.value; } inline bool operator>(const Modint &b) const { return this->value > b.value; } inline bool operator>=(const Modint &b) const { return this->value >= b.value; } // requires that "this->value and p are co-prime" // a_i * v + a_(i+1) * p = r_i // r_i = r_(i+1) * q_(i+1) * r_(i+2) // q == 1 (i > 1) // reference: https://atcoder.jp/contests/agc026/submissions/2845729 // (line:93) inline Modint inverse() const { assert(this->value != 0); int r0 = p, r1 = this->value, a0 = 0, a1 = 1; while (r1) { int q = r0 / r1; r0 -= q * r1; swap(r0, r1); a0 -= q * a1; swap(a0, a1); } return Modint(a0); } friend istream &operator>>(istream &is, Modint

&a) { long t; is >> t; a = Modint

(t); return is; } friend ostream &operator<<(ostream &os, const Modint

&a) { return os << a.value; } }; const int MOD = 1e9 + 7; using Int = Modint; //------------------------------- Type Names -------------------------------// using i64 = int_fast64_t; using seika = string; //akari : 1D, yukari : 2D, maki : 3D vector template using akari = vector; template using yukari = akari>; template using maki = akari>; //akane : ascending order, aoi : decending order template using akane = priority_queue, greater>; template using aoi = priority_queue; //------------------------------- Dubug Functions ---------------------------// inline void print() { cout << endl; } template void print(const First &first, const Rest &... rest) { cout << first << ' '; print(rest...); } //------------------------------- Solver ------------------------------------// int nibeki(int x) { int r = 0, t = 1; while (t < x) { t *= 2; r++; } if (t == x) { r++; } return r; } void solve() { int d, l, r, k; cin >> d >> l >> r >> k; l = nibeki(l); r = nibeki(r); int p = 1; //print(l, r); while (l + r - 2 * p > k) { p++; } if (l + r - 2 * p != k || l < p) { cout << 0 << endl; return; } l -= p - 1; r -= p - 1; //print(p, l, r); Int ans = 1; for (int x = 1; x <= d; x++) { int c = 1 << (x - 1); if (l + p - 1 == x) c--; if (r + p - 1 == x) c--; for (int y = 1; y <= c; y++) ans *= Int(y); } ans *= max(1, (1 << (r - 2))); ans *= max(1, (1 << (l - 2))); ans *= max(1, (1 << (p - 1 + (r != 1)))); cout << ans << endl; } int main() { solve(); return 0; }