#include<iostream>
using namespace std;
const int md=1e9+7,N=6e5+2;
typedef long long LL;
int n,m,L,R,fac[N],iv[N],k;
inline void upd(int&a){a+=a>>31&md;}
inline int reduce(int x){return(x>>31&md)+x;}
inline int C(int n,int m){return(LL)fac[n]*iv[m]%md*iv[n-m]%md;}
int solve(int S,int a,int b){
	if(a*m>S)return 0;
	S-=a*m;
	int r=0;
	for(int i=0,f=1;i<=k&&S>=0;++i,f=md-f,S-=b)
	r=(r+(LL)f*C(S+n,n)%md*C(k,i))%md;
	return(LL)r*C(n,m)%md;
}
int solve(int R){
	int ans=C(n+R,n);
	for(int i=0;i*m<=R;++i)
	upd(ans-=reduce(solve(R,i,i)-solve(R,i+1,i)));
	return ans;
}
int main(){
	cin>>n>>m>>L>>R,k=n-m;
	for(int i=*fac=1;i<N;++i)fac[i]=fac[i-1]*(LL)i%md;
	iv[N-1]=317746424;
	for(int i=N-2;~i;--i)iv[i]=(i+1LL)*iv[i+1]%md;
	cout<<reduce(solve(R)-solve(L-1))<<endl;
	return 0;
}