#include<bits/stdc++.h>
const int mo=1e9+7,N=6e5+5;
int n,m,L,R,fac[N],vf[N],inv[N],i;
inline int C(int x,int y){
	return 1ll*vf[y]*vf[x-y]%mo*fac[x]%mo;
}
inline int calc(int s){
	int i,j,ans=C(s+n,n),ss=0,x;
	for(i=0;i<=s;++i){
		int z=0;
		for(j=0;1ll*(i+1)*(j+n-m)<=s && j<=m;++j){
			x=1ll*C(s-(j+n-m)*(i+1)+n,n)*C(m,j)%mo;
			if(j&1)z=(z+mo-x)%mo;else z=(z+x)%mo;
		}
		for(j=0;1ll*(i+1)*(n-m)+i*j<=s && j<=m;++j){
			x=1ll*C(s-j*i-(n-m)*(i+1)+n,n)*C(m,j)%mo;
			if(j&1)z=(z+x)%mo;else z=(z+mo-x)%mo;
		}
		ss=(ss+z)%mo;
	}
	ans=(ans+mo-1ll*ss*C(n,m)%mo)%mo;
	return ans;
}
int main(){
	for(i=*fac=*vf=1;i<N;++i)
		fac[i]=1ll*fac[i-1]*i%mo,
		inv[i]=i==1?1:1ll*(mo-mo/i)*inv[mo%i]%mo,
		vf[i]=1ll*vf[i-1]*inv[i]%mo;
	scanf("%d%d%d%d",&n,&m,&L,&R);m=n-m;
	printf("%d\n",(calc(R)+mo-calc(L-1))%mo);
	return 0;
}