#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

ll modpow(ll x, ll n, ll mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll calcTLE(ll L, ll R) {
    ll res = 0;
    for (ll x = L; x <= R; x++) {
        for (ll y = x; y <= R; y++) {
            res += (y % x == (x ^ y));
        }
    }
    return res;
}

ll calc(ll R) {
    vector< vector<ll> > dp(2, vector<ll>(2, 0));
    dp[0][0] = 1;

    for (int i = 59; i >= 0; i--) {
        vector< vector<ll> > ndp(2, vector<ll>(2, 0));

        if (dp[1][0] > 0) {
            (ndp[1][0] += dp[1][0]) %= MOD;
            (ndp[1][1] += dp[1][0]) %= MOD;
        }

        if (dp[1][1] > 0) {
            (ndp[1][1] += dp[1][1]) %= MOD;
            (ndp[1][1] += dp[1][1] * 2) %= MOD;
        }

        if (R & (1LL << i)) {
            (ndp[1][0] += dp[0][0]) %= MOD;
            (ndp[0][1] += dp[0][0]) %= MOD;

            (ndp[1][1] += dp[0][1]) %= MOD;
            (ndp[0][1] += dp[0][1] * 2) %= MOD;
        } else {

            (ndp[0][0] += dp[0][0]) %= MOD;
            (ndp[0][1] += dp[0][1]) %= MOD;
        }

        dp = move(ndp);
    }

    ll res = 0;
    for (int i = 0; i < 2; i++) {
        (res += dp[i][1]) %= MOD;
    }
    return res;
}

ll calc(ll L, ll R) {
    vector< vector< vector<ll> > > dp(2, vector< vector<ll> >(2, vector<ll>(2, 0)));
    dp[0][0][0] = 1;

    for (int i = 59; i >= 0; i--) {
        vector< vector< vector<ll> > > ndp(2, vector< vector<ll> >(2, vector<ll>(2, 0)));
        
        if (dp[1][0][0] > 0) {
            if (!(L & (1LL << i))) (ndp[1][0][0] += dp[1][0][0]) %= MOD;
            if (!(L & (1LL << i))) {
                (ndp[1][1][1] += dp[1][0][0]) %= MOD;
            } else {
                (ndp[1][1][0] += dp[1][0][0]) %= MOD;
            }
        }

        if (dp[1][0][1] > 0) {
            (ndp[1][0][1] += dp[1][0][1]) %= MOD;
            (ndp[1][1][1] += dp[1][0][1]) %= MOD;
        }

        if (dp[1][1][0] > 0) {
            if (!(L & (1LL << i))) (ndp[1][1][0] += dp[1][1][0] * 2) %= MOD;
            if (!(L & (1LL << i))) {
                (ndp[1][1][1] += dp[1][1][0]) %= MOD;
            } else {
                (ndp[1][1][0] += dp[1][1][0]) %= MOD;
            }
        }

        if (dp[1][1][1] > 0) {
            (ndp[1][1][1] += dp[1][1][1]) %= MOD;
            (ndp[1][1][1] += dp[1][1][1] * 2) %= MOD;
        }

        if (R & (1LL << i)) {
            if (!(L & (1LL << i))) (ndp[1][0][0] += dp[0][0][0]) %= MOD;
            if (!(L & (1LL << i))) {
                (ndp[0][1][1] += dp[0][0][0]) %= MOD;
            } else {
                (ndp[0][1][0] += dp[0][0][0]) %= MOD;
            }

            // y = 0, x = 0
            if (!(L & (1LL << i))) (ndp[1][1][0] += dp[0][1][0]) %= MOD;

            // y = 1, x = 0
            if (!(L & (1LL << i))) (ndp[0][1][0] += dp[0][1][0]) %= MOD;

            // y = 1, x = 1
            if (!(L & (1LL << i))) {
                (ndp[0][1][1] += dp[0][1][0]) %= MOD;
            } else {
                (ndp[0][1][0] += dp[0][1][0]) %= MOD;
            }
            
            (ndp[1][0][1] += dp[0][0][1]) %= MOD;
            (ndp[0][1][1] += dp[0][0][1]) %= MOD;

            (ndp[1][1][1] += dp[0][1][1]) %= MOD;
            (ndp[0][1][1] += dp[0][1][1] * 2) %= MOD;
        } else {
            if (!(L & (1LL << i))) {
                (ndp[0][0][0] += dp[0][0][0]) %= MOD;
                (ndp[0][1][0] += dp[0][1][0]) %= MOD;
            }

            (ndp[0][0][1] += dp[0][0][1]) %= MOD;
            (ndp[0][1][1] += dp[0][1][1]) %= MOD;
        }

        dp = move(ndp);
    }

    ll res = 0;
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            (res += dp[i][1][j]) %= MOD;
        }
    }
    return res;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    /*
    for (ll L = 1; L <= 20; L++) {
        for (ll R = L; R <= 20; R++) {
            cout << "(" << L << ", " << R << ") " << calc(L,R) << " " << calcTLE(L, R) << endl;
        }
    }//*/

    //*
    ll L, R;
    cin >> L >> R;
    cout << calc(L, R) << endl;//*/
    return 0;
}

Measured memory_bytes: 256