#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long long solve(long long l, long long r) {

        // int ret = 0;
        // for (int i = l; i <= r; ++i) {
        //     for (int j = l; j <= r; ++j) {
        //         if ((j & i) == i && (j ^ i) < i) {
        //             ++ret;
        //         }
        //     }
        // }
        // cout << ret << endl;

        const long long MOD = 1e9 + 7;
        auto bin = [&](long long x) {
            string res;
            while (x != 0) {
                res += '0' + (x & 0x1);
                x >>= 1;
            }
            reverse(res.begin(), res.end());
            return res;
        };
        string L = bin(l);
        string R = bin(r);
        int n = R.length();
        if (L.length() < n) {
            L = string(n - L.length(), '0') + L;
        }
        // cout << L << endl;
        // cout << R << endl;
        int m = 2;
        int M = 1 << m;
        vector<vector<long long>> dp(M, vector<long long>(M, 0));
        auto ndp = dp;
      
        for (int i = 0; i < n; ++i) {
            int a = L[i] - '0';
            int b = R[i] - '0';

            for (auto& V : ndp) {
                for (auto& x : V) {
                    x = 0;
                }
            }

            for (int j = 0; j < M; ++j) {
                int l = 0, r = 1;
                if ((j & 1) == 0) {
                    l = max(l, a);
                }
                if ((j & 2) == 0) {
                    r = min(r, b);
                }
                for (int k = 0; k < M; ++k) {
                    int ll = 0, rr = 1;
                    if ((k & 1) == 0) {
                        ll = max(ll, a);
                    }
                    if ((k & 2) == 0) {
                        rr = min(rr, b);
                    }

                    for (int x = l; x <= r; ++x) {
                        for (int y = ll; y <= rr; ++y) {
                            if (x == 1 && y == 0) {
                                continue;
                            }
                            int nj = j;
                            int nk = k;
                            if (x > a) {
                                nj |= 1;
                            }
                            if (x < b) {
                                nj |= 2;
                            }
                            if (y > a) {
                                nk |= 1;
                            }
                            if (y < b) {
                                nk |= 2;
                            }
                            ndp[nj][nk] += dp[j][k];
                            ndp[nj][nk] %= MOD;
                        }
                    }
                }
             }
           

            swap(ndp, dp);

            {
                int j = 0;
                string p = string(i, '0');
                p += '1';                
                if (p > L.substr(0, i + 1)) {
                    j |= 1;
                }
                if (p < R.substr(0, i + 1)) {
                    j |= 2;
                }
                if (p < L.substr(0, i + 1)) {

                } else {
                    dp[j][j] += 1;
                    dp[j][j] %= MOD;
                }
            }
            // for (int i = 0; i < M; ++i){
            //     for (int j = 0; j < M; ++j) {
            //         if (dp[i][j] > 0) {
            //             cout << i << "," << j << " " << dp[i][j] << endl;
            //         }
            //     }
            // }
            // cout << endl;
        }

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

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    long long l, r;
    cin >> l >> r;
    Solution sol;
    cout << sol.solve(l, r) << "\n";

    return 0;
}

Measured memory_bytes: 256