#include #include using namespace std; typedef long long ll; constexpr ll MOD = 1000000007; constexpr int N_MAX = 1 << 20; ll fact[N_MAX+1]; void init(ll n){ fact[0] = fact[1] = 1; for(int i=2;i<=n;++i) { fact[i] = (fact[i-1] * (ll)i) % MOD; ll k = MOD-2; ll a = fact[i]; while(k > 0){ a *= a; a %= MOD; k >>= 1; } } } int main() { ll d, l, r, k; cin >> d >> l >> r >> k; init(1LL << d); ll ld = 0, rd = 0; while((1LL << (ld+1)) <= l) ++ld; while((1LL << (rd+1)) <= r) ++rd; if(ld+rd > 2*d) { cout << 0 << endl; return 0; } ll lca_d = 0; while(ld+rd - 2*lca_d > k && lca_d <= min(ld, rd)) { ++lca_d; } if(ld+rd - 2*lca_d != k) { cout << 0 << endl; return 0; } ll ans = 0; // l と r の置き方 if(ld == lca_d) { ans = (((1LL << (rd-ld)) % MOD) * ((1LL << ld)) % MOD) % MOD; } else { ans = (((1LL << (rd-lca_d-1)) % MOD) * ((1LL << (ld-lca_d-1))) % MOD) % MOD; ans = (ans * ((1LL << lca_d)) % MOD) % MOD; (ans *= 2LL) %= MOD; } // その他の数字の置き方 for(int i=0;i