#include using namespace std; #define REP(i,x,y) for(ll i=x; i<=y; i++) #define BIT(t) ((long long 1) << t) #define PER(i,y,x) for(ll i=y; i>=x; i--) #define SIZE(v) ll(v.size()) #define vll vector #define vvll vector> #define pll pair #define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ); typedef long long ll; ll const MOD = 1e9 + 7; ll mod_p(ll x, ll y) { x %= MOD; y %= MOD; return (x + y + MOD) % MOD; } ll mod_m(ll x, ll y) { x %= MOD; y %= MOD; return x * y%MOD; } ll mod_pow(ll x, ll t) { x %= MOD; if (t == 0) { return 1; } else { ll v = mod_pow(x, t / 2); if (t % 2 == 0) { return v * v % MOD; } else { return v * v%MOD * x %MOD; } } } ll mod_inv(ll x) { return mod_pow(x, MOD - 2); } vll fct(1e6), invfct(1e6); void init(){ fct[0] = invfct[0] = 1; REP(i,1,1e6-1){ fct[i] = mod_m(fct[i-1], i); invfct[i] = mod_inv(fct[i]); } } int main(){ init(); ll n, l, r, k; cin >> n >> l >> r >> k; ll l_dp = 0; ll r_dp = 0; while(l > 0){ l_dp++; l /= 2; } while(r > 0){ r_dp++; r /= 2; } if((l_dp + r_dp) % 2 != k % 2){ cout << 0 << endl; return 0; }else if(abs(l_dp - r_dp) > k && k > l_dp + r_dp){ cout << 0 << endl; return 0; } if(l_dp > r_dp){ swap(l_dp, r_dp); } ll tmp; if(k == r_dp - l_dp){ tmp = 1; }else{ tmp = pow(2, (k - (r_dp - l_dp)) / 2 - 1); } ll ans = 1; REP(i,1,n){ ll t = pow(2, i-1); ans = mod_m(ans, fct[t]); if(l_dp == i){ if(l_dp == r_dp){ t--; } ans = mod_m(ans, mod_inv(t)); ans = mod_m(ans, tmp); } } cout << ans << endl; }