#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

pair<long long,long long> get(long long Lx,long long Rx,int x,long long d){
	long long lx,rx;
	if(x==0){
		if((Lx>>d)&1LL)return {-1,-1};
		else lx = Lx;
		if((Rx>>d)&1LL)rx = (1LL<<d)-1LL;
		else rx=Rx;
	}
	else{
		if((Lx>>d)&1LL)lx=Lx^(1LL<<d);
		else lx=0LL;
		if((Rx>>d)&1LL)rx=Rx^(1LL<<d);
		else return {-1,-1};
	}
	return {lx,rx};
}

int Get(long long Lx,long long Rx,long long Ly,long long Ry,long long d,int f){
	if(d<0){
		if(Lx==0&&Rx==0&&Ly==0&&Ry==0)return 1;
		else return 0;
	}
	
	static map<vector<long long>,int> mp;
	vector<long long> args = {Lx,Rx,Ly,Ry,d,f};
	if(mp.count(args))return mp[args];
	
	int ret = 0;	
	for(int y=0;y<2;y++){
		for(int x=0;x<2;x++){
			if(y==0&&x==1)continue;
			if((f==0)&&x!=y)continue;
			auto [lx,rx] = get(Lx,Rx,x,d);
			auto [ly,ry] = get(Ly,Ry,y,d);
			if(lx==-1||rx==-1)continue;
			if(x==1&&y==1)ret = mod(ret +Get(lx,rx,ly,ry,d-1,1));
			else ret = mod(ret + Get(lx,rx,ly,ry,d-1,f));
					
		}
	}
	mp[args] = ret;
	return ret;
}

int main(){
	
	long long L,R;
	cin>>L>>R;
	int ans = Get(L,R,L,R,60,0);
	cout<<ans<<endl;
	
	return 0;
}
