#include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; static const ll MOD = 1000000007; ll fact[1100000]; int main(){ fact[0] = fact[1] = 1; for(ll i=2; i<1100000; i++) fact[i] = (fact[i-1] * i) % MOD; ll d, l, r, k; cin >> d >> l >> r >> k; ll li = 0, ri = 0; ll p = 1; REP(i,1,21){ if(p <= l && l < p*2){ li = i; } if(p <= r && r < p*2){ ri = i; } p *= 2; } if(k < (ri-li) || (k-(ri-li))%2 != 0){ cout << 0 << endl; }else{ ll a = (k-(ri-li))/2; ll lca = li-a; if(lca < 1){ cout << 0 << endl; return 0; } cerr << li << " " << ri << " " << a << " " << lca << endl; if(li == ri){ ll ln = 1LL << (li-1); ll rn = (1LL << (a-1)); ll ret = 1; REP(i,1,d+1){ if(i==ri){ ret *= ((ln%MOD) * (rn%MOD))%MOD; ret %= MOD; ret *= fact[(1LL << (ll)(i-1)) - 2]; ret %= MOD; }else{ ret *= fact[(1LL << (ll)(i-1))]; ret %= MOD; } } cout << ret << endl; }else{ ll ln = 1LL << (li-1); ll rn = 1LL << (ri-lca-1); if(a==0){ rn *= 2; rn %= MOD; } cerr << ln << " " << rn << endl; ll ret = ((ln%MOD) * (rn%MOD))%MOD;; REP(i,1,d+1){ if(i==li || i==ri){ ret *= fact[(1LL << (ll)(i-1)) - 1]; ret %= MOD; } else{ ret *= fact[(1LL << (ll)(i-1))]; ret %= MOD; } } cout << ret << endl; } } return 0; }