#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair P; const ll MOD=1e9+7; ll powmod(ll a, ll k){ ll ap=a, ans=1; while(k){ if(k&1){ ans*=ap; ans%=MOD; } ap=ap*ap; ap%=MOD; k>>=1; } return ans; } ll inv(ll a){ return powmod(a, MOD-2); } ll f[5000001], invf[5000001]; void fac(int n){ f[0]=1; for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD; invf[n]=inv(f[n]); for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD; } int main() { int d, l, r, k; cin>>d>>l>>r>>k; int dl=0, dr=0; int l1=l, r1=r; while(l1){ dl++; l1>>=1; } while(r1){ dr++; r1>>=1; } dl--; dr--; if((dl+dr)%2!=k%2 || dl+dr=dp; i--){ if(dl!=dr) c[i]=(1ll<<(dl-i+dr-i))%MOD; else{ ll x=(1<<(dl-i)); c[i]=x*(x-1)%MOD; } (c[i]*=(1ll<