#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

template <std::uint_fast64_t Modulus> 
struct ModInt {
    using u64 = std::uint_fast64_t;

    u64 a;

    constexpr ModInt(const long long x = 0) noexcept : a(x >= 0 ? x % Modulus : (Modulus - (-x) % Modulus) % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr ModInt operator+(const ModInt rhs) const noexcept {return ModInt(*this) += rhs;}
    constexpr ModInt operator-(const ModInt rhs) const noexcept {return ModInt(*this) -= rhs;}
    constexpr ModInt operator*(const ModInt rhs) const noexcept {return ModInt(*this) *= rhs;}
    constexpr ModInt operator/(const ModInt rhs) const noexcept {return ModInt(*this) /= rhs;}
    constexpr ModInt operator^(const long long rhs) const noexcept {return ModInt(*this) ^= rhs;}
    constexpr ModInt &operator+=(const ModInt rhs) noexcept {
        a += rhs.a;
        if (a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr ModInt &operator-=(const ModInt rhs) noexcept {
        if (a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr ModInt &operator*=(const ModInt rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr ModInt &operator/=(ModInt rhs) noexcept {
        u64 exp = Modulus - 2;
        while (exp) {
            if (exp&1) *this *= rhs;
            exp >>= 1;
            rhs *= rhs;
        }
        return *this;
    }
    constexpr ModInt &operator^=(long long exp) noexcept {
        ModInt rhs = a;
        a = 1;
        while (exp) {
            if (exp&1) *this *= rhs;
            exp >>= 1;
            rhs *= rhs;
        }
        return *this;
    }

    bool operator==(const ModInt &p) const {return a == p.a;}
    bool operator!=(const ModInt &p) const {return a != p.a;}

};

using mint = ModInt<MOD>;

mint calc1(ll x, ll N) {
    vector<mint> dp1(65),dp2(65);
    dp1[0] = 1;
    rep(i,64) {
        if ((x>>(63-i))&1) {
            if ((N>>(63-i))&1) {
                dp1[i+1] = dp1[i];
                dp2[i+1] = dp2[i];
            } else {
                dp2[i+1] = dp2[i];
            }
        } else {
            if ((N>>(63-i))&1) {
                dp1[i+1] = dp1[i];
                dp2[i+1] = dp2[i]*2 + dp1[i];
            } else {
                dp1[i+1] = dp1[i];
                dp2[i+1] = dp2[i]*2;
            }
        }
    }

    return dp1[64] + dp2[64];
}

mint calc2(ll x, ll N) {
    if (N <= 0) return 0;
    vector<mint> dp1(65),dp2(65);
    dp1[0] = 1;
    rep(i,64) {
        if ((x>>(63-i))&1) {
            if ((N>>(63-i))&1) {
                dp1[i+1] = dp1[i];
                dp2[i+1] = dp2[i]*2 + dp1[i];
            } else {
                dp1[i+1] = dp1[i];
                dp2[i+1] = dp2[i]*2;
            }
        } else {
            if ((N>>(63-i))&1) {
                dp2[i+1] = dp2[i] + dp1[i];
            } else {
                dp1[i+1] = dp1[i];
                dp2[i+1] = dp2[i];
            }
        }
    }

    return dp1[64] + dp2[64];
}

mint dfs(ll L, ll R) {
    if (L==R) return 0;
    if (L%2==1) {
        return dfs(L+1,R) + calc1(L,min(R-1,L*2-1));
    } else if (R%2==1) {
        return dfs(L,R-1) + calc2(R-1,R-1) - calc2(R-1,max(L-1,(R-1)/2));
    } else {
        return dfs(L>>1,R>>1)*3;
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll L,R; cin >> L >> R;
    cout << dfs(L,R+1).a << ln;
}

Measured memory_bytes: 256