#include <bits/stdc++.h>

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int getbit(const LL x, const int i)
{ return (x>>i) & 1; }          /* Returns the i-th bit value of x. */

/*
 * The pattern shows that if a = [1][0]..[1]..[0], b will have all the
 * 1s where a has, and all the 0s positions, b can have either 0 or 1.
 */
/*
 * For this problem dp[R]-dp[L-1] will not work, because the 2 numbers,
 * one can in [1,L-1], the other in [L,R].
 */

const int mod = 1e9+7;
const int maxn = 61;
/*
 * dp(i,hasA,gtL,limitA,limitB)
 * i is th i-th bit
 * hasA is we have picked a 1 for number a (b is bounded by the 1s of a)
 * gtL is the number a we pick is greater than L
 * limitA is the number a we pick is limited by R's bit
 * limitB is the number b we pick is limited by R's bit
 */
LL L,R; int dp[maxn][2][2][2][2];

int hibit(const LL x)
{
    FORR(i,maxn-1,-1) if (x & (1LL<<i))
        return i;
    return -1;
}

int dfs(
    const int i,
    const bool hasA, const bool gtL,
    const bool limitA,  const bool limitB)
{
    if (i < 0)
        return hasA;
    int& ans = dp[i][hasA][gtL][limitA][limitB];
    if (-1 == ans) {
        ans = 0;
        const int bitL  = getbit(L,i);
        const int bitR  = getbit(R,i);
        const int frstA = gtL ? 0 : bitL;
        const int lastA = limitA ? bitR : 1;
        const int lastB = limitB ? bitR : 1;
        FOR(a,frstA,lastA+1) {
            const bool gt = gtL || (bitL < a);
            if (a == 1) {       /* if a pick 1, b must pick 1 */
                if (lastB == 1) {
                    ans += dfs(i-1, true, gt, limitA, limitB);
                    ans %= mod;
                }
            }
            else {
                FOR(b,0,lastB+1) {
                    /* if have not pick 1 for a yet, b can't have 1 */
                    if (!hasA && b == 1)
                        continue;
                    const bool lmtA = limitA && a == lastA;
                    const bool lmtB = limitB && b == lastB;
                    ans += dfs(i-1, hasA, gt, lmtA, lmtB);
                    ans %= mod;
                }
            }
        }
    }
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    while (cin >> L >> R) {
#ifdef foo_debug
        int cnt = 0;
        cout << L << ' ' << R << endl;
        FOR(x,L,R+1) FOR(y,x,R+1) {
            const bool good = (y%x == (x^y));
            if (good) {
                if (1 || hibit(x) != hibit(y))
                    cout << bitset<8>(x) << ' ' << bitset<8>(y) << endl;
                cnt++;
            }
        }
        cout << cnt << endl;
#endif
        memset(dp,-1,sizeof(dp));
        const int ans = dfs(maxn-1, false, false, true, true);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256