#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3") 
#pragma GCC optimization ("unroll-loops")
 
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;
 
#define ll  long long
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define ppi pair<pii,ll>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)
 
#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)
 
#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount
#define die() return 0;
#define sz() size() 


 
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define MD          1000000007
#define M 			200011
#define LN             14
#define fftmod      998244353
#define EPS         (double)1e-10
 
long long  md=MD;
ll inf=1e18;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
 
inline ll exp(ll a,ll b){if(a==0&&b==0)return 1ll;if(a==0)return 0ll;ll r=1LL;while(b>0){if(b&1){r=(r%md)*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}
 
using cd=complex<double>;
const double PI=acos(-1);
 
inline ll rand(ll l,ll r){
    return l+rng()%(r-l+1);
}

vii l,h;

ll dp[100][2][2][2];
ll f(ll x,ll c,ll k1,ll k2){
	if(x<0){
		return c==0;
	}
	ll i,j;
	ll ans=0;
	// swap(k1,k2);
	if(dp[x][c][k1][k2]!=-1)return dp[x][c][k1][k2];
	if(c==0){
		if(!k1&&!k2){
			ans+=3*f(x-1,0,0,0)%md;
		}
		else if(k1&&k2){
			if(0>=l[x]&&0<=h[x]){
				ll a=k1,b=k2;
				if(l[x]!=0)a=0;
				if(h[x]!=0)b=0;
				ans+=f(x-1,0,a,b)%md;

			}
			if(0>=l[x]&&1<=h[x]){
				ll a=k1,b=k2;
				if(l[x]!=0)a=0;
				if(h[x]!=1)b=0;
				ans+=f(x-1,0,a,b)%md;

			}
			if(1>=l[x]&&1<=h[x]){
				ll a=k1,b=k2;
				if(l[x]!=1)a=0;
				if(h[x]!=1)b=0;
				ans+=f(x-1,0,a,b)%md;
			}

		}
		else if(!k1&&k2){
			if(0<=h[x]){
				ll a=k1,b=k2;
				if(h[x]!=0)b=0;
				ans+=f(x-1,0,a,b)%md;
			}
			if(1<=h[x]){
				ll a=k1,b=k2;
				if(h[x]!=1)b=0;
				ans+=2*f(x-1,0,a,b)%md;
			}


		}
		else{
			if(0>=l[x]){
				ll a=k1,b=k2;
				if(l[x]!=0)a=0;
				if(h[x]!=1)b=0;
				ans+=2*f(x-1,0,a,b)%md;
			}
			if(1>=l[x]){
				ll a=k1,b=k2;
				if(l[x]!=1)a=0;
				if(h[x]!=1)b=0;
				ans+=f(x-1,0,a,b)%md;

			}

		}

	}
	else{
		if(!k1&&!k2){
			ans+=f(x-1,1,0,0)%md;

		}
		else if(k1&&k2){
			if(1>=l[x]&&1<=h[x]){
				ll a=k1,b=k2;
				if(l[x]!=1)a=0;
				if(h[x]!=1)b=0;
				ans+=f(x-1,1,a,b)%md;
			}

		}
		else if(!k1&&k2){
			if(1<=h[x]){
				ll a=k1,b=k2;
				if(h[x]!=1)b=0;
			
				ans+=f(x-1,1,a,b)%md;
			}
			



		}
		else{
			if(1>=l[x]){
				ll a=k1,b=k2;
				if(l[x]!=1)a=0;
				ans+=f(x-1,1,a,b)%md;

			}

		}




	}
	if(!k1&&!k2){
		dp[x][c][k1][k2]=ans%md;
	}
	return ans%md;
}


int main(){
 
     
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
 
   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p;string s1,s2;ll q;ll x,y;
    cin>>x>>y;
    vii a,b;
    memset(dp,-1,sizeof(dp));
    while(x){
    	a.pb(x%2);x/=2;
    }
    while(y){
    	b.pb(y%2);y/=2;
    }
    n=a.size();
    p=0;
    if(a.size()==b.size()){
    	l=a;h=b;
    		// for(auto x:l)cout<<x<<" ";cout<<"\n";
    		// for(auto x:h)cout<<x<<" ";cout<<"\n";
		p+=f(n-1,0,1,1)%md;
	p%=md;
		cout<<p<<"\n";
    	die();
    }
    while(n<=b.sz()){
    	if(n==b.sz()){
    		h=b;
    		l.clear();
    		for(i=0;i<n-1;++i)l.pb(0);
    		l.pb(1);
    		// for(auto x:l)cout<<x<<" ";cout<<"\n";
    		// for(auto x:h)cout<<x<<" ";cout<<"\n";
    		p+=f(n-1,0,1,1)%md;

    	}
    	else if(n==a.sz()){
    		l=a;
    		h.clear();
    		for(i=0;i<n;++i)h.pb(1);
    		// for(auto x:l)cout<<x<<" ";cout<<"\n";
    		// for(auto x:h)cout<<x<<" ";cout<<"\n";
    		p+=f(n-1,0,1,1)%md;

    	}
    	else{
    		l.clear();
    		h.clear();
    		for(i=0;i<n;++i)h.pb(1),l.pb(0);
    		l.pop_back();l.pb(1);

    		// for(auto x:l)cout<<x<<" ";cout<<"\n";
    		// for(auto x:h)cout<<x<<" ";cout<<"\n";
    		p+=f(n-1,0,1,1)%md;

    
    	}
    	n++;p%=md;
    }
    cout<<p<<"\n";



    





    	






    

}



Measured memory_bytes: 256