#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MOD = (int)1e9 + 7;
const int BITS = 63;

int add(int x, int y) {
	return (x + y >= MOD ? x + y - MOD : x + y);
}

int mult(int x, int y) {
	return (x * 1LL * y) % MOD;
}

vector<int> convert(ll number) {
	vector<int> rez(BITS);

	for(int i = 0; i < BITS; ++i) {
		rez[BITS - 1 - i] = number & 1;
		number /= 2;
	}

	return rez;
}

int first_one(const vector<int>& seq) {
	for(int i = 0; i < len(seq); ++i) {
		if(seq[i] == 1) {
			return i;
		}
	}

	return NIL;
}

int pow3[BITS];

void precalc() {
	pow3[0] = 1;

	for(int i = 1; i < BITS; ++i) {
		pow3[i] = mult(3, pow3[i - 1]);
	}
}

void solve() {
	auto L = convert(fetch<ll>() - 1);
	auto R = convert(fetch<ll>() + 1);
	int answ = 0;

	DBG(L); DBG(R);

	for(int i = 0; i < BITS; ++i) {
		if(L[i] == 1) {
			continue;
		}

		for(int j = 0; j < BITS; ++j) {
			if(R[j] == 0) {
				continue;
			}

			vector<int> x(BITS, NIL), y(BITS, NIL);

			for(int k = 0; k < i; ++k) {
				x[k] = L[k];
			}

			x[i] = L[i] ^ 1;

			for(int k = 0; k < j; ++k) {
				y[k] = R[k];
			}

			y[j] = R[j] ^ 1;
			int lt = 1;

			for(int k = 0; k < BITS; ++k) {
				if(x[k] == 1 && y[k] == 0) {
					lt = 0;
					break;
				}
			}

			int fstx = first_one(x);
			int fsty = first_one(y);

			if(lt && (fstx == fsty || fstx == NIL || fsty == NIL)) {
				DBG(x); DBG(y);
				vector<int> dp(BITS + 1, 1);

				for(int i = BITS - 1; i >= 0; --i) {
					dp[i] = 0;
					
					for(int xb = 0; xb <= 1; ++xb) {
						for(int yb = xb; yb <= 1; ++yb) {
							if((x[i] == xb || x[i] == -1) && (y[i] == yb || y[i] == -1)) {
								dp[i] = add(dp[i], dp[i + 1]);
							}
						}
					}
				}

				for(int k = 0; k < BITS; ++k) {
					if(x[k] != 0 && y[k] != 0) {
						answ = add(answ, dp[k + 1]);
					}

					if(x[k] == 1 || y[k] == 1) {
						break;
					}
				}
			}
		}
	}

	cout << answ << '\n';
}

int main() {
	fast_io();

	precalc();
	solve();

	return 0;
}


Measured memory_bytes: 256