#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll beki(ll a, ll b) {
    if(b == 0) return 1;
    ll ret = beki(a, b / 2);
    ret = ret * ret % mod;
    if(b & 1) ret = ret * a % mod;
    return ret;
}

int f(int i) {
    if(i == 1) return 0;
    return 1 + f(i / 2);
}

ll ans;

ll upper2(ll L, ll idx) {
    ll ret = 0;
    for(ll x = L; x < (1LL << (idx + 1)); x++) {
        for(ll y = x; y < (1LL << (idx + 1)); y++) {
            if((y&x) == x) ret++;
        }
    }
    ret %= mod;
    //cerr << "upper: " << L << " " << idx << " " << ret << endl;
    return ret;
}

ll upper(ll L, ll idx) {
    if(idx < 0) return 0;
    if(L >= (1LL << (idx + 1))) return 0;
    //cerr << "upper: " << L << " " << idx << endl;
    ll ret = 0;
    if(L <= 0) {
        ret = beki(3, idx + 1);
    } else if(idx == 0) {
        if(L == 1) {
            ret = 1;
        }
    } else {
        ret += 2 * upper(L, idx - 1);
        ret += upper(L - (1LL << idx), idx - 1);
    }
    ret %= mod;
    return ret;
}

ll lower2(ll R, ll idx) {
    ll ret = 0;
    for(ll x = 0; x <= min(R, (1LL << (idx + 1)) - 1); x++) {
        ret += beki(2, __builtin_popcount(x));
    }
    ret %= mod;
    //cerr << "lower: " << R << " " << idx << " " << ret << endl;
    return ret;
}

ll lower(ll R, ll idx) {
    ll ret = 0;
    if(R < 0) return 0;
    if(R == 0) return 1;
    if(R >= (1LL << (idx + 1))) {
        return beki(3, idx + 1);
    }
    ret += 2 * lower(R - (1LL << idx), idx - 1);
    ret += lower(R, idx - 1);
    ret %= mod;
    //cerr << "lower: " << R << " " << idx << " " << ret << endl;
    //cerr << lower2(R, idx) << endl;
    return ret;
}

ll g(ll R, ll L, ll idx) {
    //cerr << "g: " << R << " " << L << " " << idx << endl;
    if(R < 0) return 0;
    //if(R < L) return 0;
    if(L <= 0) return lower(R, idx);
    if((1LL << (idx + 1)) <= R) return upper(L, idx);
    if(idx <= 1) {
        ll ret = 0;
        for(ll x = L; x <= R; x++) {
            for(ll y = x; y <= R; y++) {
                if((x & y) == x) ret++;
            }
        }
        return ret;
    }
    ll ret = 0;
    ret += g(R - (1LL << idx), L - (1LL << idx), idx - 1);
    ret += g(R - (1LL << idx), L, idx - 1);
    ret += g(R, L, idx - 1);
    return ret % mod;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll L, R;
    cin >> L >> R;
    cerr << bitset<60>(L) << " ";
    cerr << bitset<60>(R) << endl;
    /*
    for(ll i = L; i <= R; i++) {
        for(ll j = i; j <= R; j++) {
            bool one = ((j%i) == (j^i));
            bool two = (f(j) == f(i)) and ((j&i) == i);
            //cerr << i << " " << j << " " << one << " " << two << endl;
            assert(one == two);
        }
    }
    */
    for(ll i = 61; i >= 0; i--) {
        ll val = 1LL << i;
        if(val > R or L > val * 2) continue;
        ll tmp = g(R - (1LL << i), L - (1LL << i), i - 1);
        cerr << i << " " << tmp << endl;
        ans += tmp;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256