/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct modint{
    ll a;
    const ll MOD=1e9+7;
    modint(ll a_=0){
        a=((a_%MOD)+MOD)%MOD;
    }
    modint inv()const{
        ll n=1,m=MOD-2,A=a;
        while(m){
            if(m&1)(n*=A)%=MOD;
            (A*=A)%=MOD;
            m>>=1;
        }
        modint y(n);
        return y;
    }
    bool operator==(const modint& x){
        return a==x.a;
    }
    bool operator!=(const modint& x){
        return a!=x.a;
    }
    modint& operator=(const modint& x){
        a=x.a;
        return *this;
    }
    modint operator+(const modint& x){
        modint y(a+x.a);
        return y;
    }
    modint operator-(const modint& x){
        modint y(a-x.a);
        return y;
    }
    modint operator*(const modint& x){
        modint y(a*x.a);
        return y;
    }
    modint operator/(const modint& x){
        return *this * x.inv();
    }
    modint& operator+=(const modint& x){
        *this=*this+x;
        return *this;
    }
    modint& operator-=(const modint& x){
        *this=*this-x;
        return *this;
    }
    modint& operator*=(const modint& x){
        *this=*this*x;
        return *this;
    }
    modint& operator/=(const modint& x){
        *this=*this/x;
        return *this;
    }
};
istream& operator>>(istream &in,modint& x){
    ll a_;
    in>>a_;
    modint y(a_);
    x=y;
    return in;
}
ostream& operator<<(ostream &out,const modint& x){
    out<<x.a;
    return out;
}
modint pwr(ll a,ll b){
    modint n(1),A(a);
    while(b){
        if(b&1) n*=A;
        A*=A;
        b>>=1;
    }
    return n;
}

class FCoincidence {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        using i64=int_fast64_t;
        i64 l,r;
        in>>l>>r;
        ++r;--l;
        ifr(i,62){
            if(((l^r)>>i)&1){
                l%=(1ll<<(i+1));
                r%=(1ll<<(i+1));
                break;
            }
        }
        modint ans;
        fr(i,62){
            i64 k=1ll<<i,t=k<<1;
            if(l<k&&t<=r){
                //cout<<1<<endl;
                ans+=pwr(3,i);
            }
            if(k<=l&&l<t-1&&t<=r){
                //cout<<2<<endl;
                int a=0;
                ifr(j,i){
                    if(((l>>j)&1)==0){
                        //cout<<"#"<<a<<" "<<pwr(3,j)*pwr(2,a)<<endl;
                        ans+=pwr(3,j)*pwr(2,a);
                        ++a;
                    }
                }
            }
            if(l<k&&k<r&&r<t){
                //cout<<3<<endl;
                int a=0;
                ifr(j,i){
                    if((r>>j)&1){
                        ans+=pwr(3,j)*pwr(2,a);
                        ++a;
                    }
                }
            }
            //cout<<i<<" "<<ans<<endl;
        }
        out<<ans<<endl;
    }
};

int main() {
    FCoincidence solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256