#include #define int long long using namespace std; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } template class ModInt { private: int val; public: int value(){ return val; } ModInt(int x=0){ val=x%mod; } ModInt pow(int n){ ModInt res(1),x(val); while(n>0){ if(n&1) res*=x; x*=x; n>>=1; } return res; } ModInt inv(){ return pow(mod-2); } ModInt& operator+=(ModInt rhs){ val+=rhs.val; if(val>=mod) val-=mod; return *this; } ModInt& operator-=(ModInt rhs){ val+=mod-rhs.val; if(val>=mod) val-=mod; return *this; } ModInt& operator*=(ModInt rhs){ val=val*rhs.val%mod; return *this; } ModInt& operator/=(ModInt rhs){ *this*=rhs.inv(); return *this; } ModInt operator+(ModInt rhs){ return ModInt(val)+=rhs; } ModInt operator-(ModInt rhs){ return ModInt(val)-=rhs; } ModInt operator*(ModInt rhs){ return ModInt(val)*=rhs; } ModInt operator/(ModInt rhs){ return ModInt(val)/=rhs; } }; signed main() { cin.tie(0); ios::sync_with_stdio(false); int d,l,r,k; cin>>d>>l>>r>>k; const int N=(1<> G(N+1); for(int i=1;i<1<<(d-1);i++){ G[i].push_back(2*i); G[2*i].push_back(i); G[i].push_back(2*i+1); G[2*i+1].push_back(i); } vector dist(N+1); function dfs=[&](int v,int p) { for(int u:G[v]) if(u!=p){ dist[u]=dist[v]+1; dfs(u,v); } }; int depthL=32-__builtin_clz(l); int depthR=32-__builtin_clz(r); dfs(1<<(depthL-1),-1); // for(int i=1;i<=N;i++) cout<; mint ans=0; for(int i=1<<(depthR-1);i<1< fact(N+1); fact[0]=1; for(int i=1;i<=N;i++) fact[i]=fact[i-1]*i; for(int i=1;i<=d;i++){ int j=1<<(i-1); if(i==depthL) j--; if(i==depthR) j--; ans*=fact[j]; } ans*=1<<(depthL-1); cout<