#include <numeric>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <iostream>
#include <sstream>
#include <vector>
#include <cstdio>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <string>
#include <bitset>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <tuple>
#include <sstream>

using namespace std;

#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; for (auto& e : a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; for (auto& e : a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; for (auto& r : a) { for (auto& e : r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; for (auto& e : a) { cerr << e.field << " ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif

#define forn(a, e) for (int a = 0; a < (int)e; a++)
#define forr(a, s, e) for (int a = s; a < (int)e; a++)

using i64 = long long;

template<typename T>
using Pair = array<T, 2>;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    i64 l, r;
    while (cin >> l >> r) {
        auto bin = [](i64 num) {
            vector<int> res;
            while (num) {
                res.push_back(num % 2);
                num /= 2;
            }
            return res;
        };

        auto numr = bin(r);
        auto numl = bin(l);
        while (numl.size() < numr.size()) {
            numl.push_back(0);
        }

        const i64 M = 1e9 + 7;
        vector<vector<vector<i64>>> dp(numl.size(), vector<vector<i64>>(2, vector<i64>(2, -1)));

        function<i64(int, bool, bool)> rec = [&](int pos, bool brr, bool brl) {
            if (pos < 0) {
                return 1ll;
            }

            if (dp[pos][brr][brl] != -1) {
                return dp[pos][brr][brl];
            }

            i64 res = 0;
            if (brr) {
                if (brl) {
                    res = 3 * rec(pos - 1, brr, brl);
                } else {
                    if (numl[pos] == 1) {
                        res = rec(pos - 1, brr, brl);
                    } else {
                        res += (2 * rec(pos - 1, brr, false)) % M;
                        res += rec(pos - 1, brr, true);
                        res %= M;
                    }
                }
            } else {
                if (numr[pos] == 1) {
                    if (brl) {
                        res += (2 * rec(pos - 1, false, brl)) % M;
                        res += rec(pos - 1, true, brl);
                        res %= M;
                    } else {
                        if (numl[pos] == 1) {
                            res += rec(pos - 1, false, brl);
                        } else {
                            res += rec(pos - 1, false, false);
                            logss(pos, res);
                            res %= M;
                            res += rec(pos - 1, false, true);
                            res %= M;
                            logss(pos, res);
                            res += rec(pos - 1, true, false);
                            res %= M;
                            logss(pos, res);
                        }
                    }
                } else {
                    if (brl) {
                        res += rec(pos - 1, false, brl);
                    } else if (numl[pos] == 0) {
                        res += rec(pos - 1, false, false);
                    }
                }
            }
            res %= M;
            return dp[pos][brr][brl] = res;
        };

        i64 c2 = 0;
        for (int i = numl.size() - 1; i >= 0; i--) {
            if (numl[i] == 1) {
                c2 += rec(i - 1, i < numl.size() - 1, false);
                break;
            } else {
                c2 += rec(i - 1, i < numl.size() - 1, true);
            }
            c2 %= M;
        }
        cout << c2 % M << endl;
    }
}


Measured memory_bytes: 384