#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int K = 60, MOD = 1e9 + 7;
ll L, R, l, r;

int f(ll x) {
	for (int i = K - 1; i >= 0; i--) {
		if (x >> i & 1) {
			return i;
		}
	}
	return -1;
}

vi vl, vr;
int LEN;

void process() {
	vl.clear(), vr.clear();
	ll l0 = l, r0 = r;
	do {
		vl.pb(l0 & 1);
		l0 /= 2;
	}	while (l0);
	while ((int)vl.size() < LEN) {
		vl.pb(0);
	}
	reverse(all(vl));
	do {
		vr.pb(r0 & 1);
		r0 /= 2;
	}	while (r0);
	while ((int)vr.size() < LEN) {
		vr.pb(0);
	}
	reverse(all(vr));
}

int dp[2][K + 1][K + 1], suf1[K + 1], suf2[K + 1], total[K + 1];

void add(int & x, int y) {
	x += y;
	if (x >= MOD) {
		x -= MOD;
	}
}

int calc(int f, int len, int z) {
	if (len == LEN) {
		return (1ll << z) % MOD;
	}
	int & res = dp[f][len][z];
	if (res != -1) {
		return res;
	}
	res = 0;
	for (int i = 0; i < 2; i++) {
		if (!f || (f && i >= vl[len])) {
			add(res, calc(f && (i == vl[len]), len + 1, z + (i == 0)));
		}
	}
	return res;
}

int fact[K + 1], rev[K + 1];

int bp(int x, int y) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = (ll)res * x % MOD;
		}
		x = (ll)x * x % MOD;
		y /= 2;
	}
	return res;
}

int C(int x, int y) {
	if (x > y) {
		return 0;
	}
	return ((ll)fact[y] * rev[x] % MOD) * rev[y - x] % MOD;
}

int solve() {
	// find number of l <= x <= y <= r, x is submask of y
	memset(& suf1, 0, sizeof(suf1));
	memset(& suf2, 0, sizeof(suf2));
	memset(& total, 0, sizeof(total));
	//cout << "l r " << l << ' ' << r << '\n';
	process();
	//for (int i : vl) {
		//cout << i;
	//}
	//cout << '\n';
	//for (int i : vr) {
		//cout << i;
	//}
	//cout << '\n';
	int z = 0;
	for (int i = LEN - 1; i >= 0; i--) {
		z += (vl[i] == 0);
		suf1[i] = (1ll << z) % MOD;
		memset(& dp, -1, sizeof(dp));
		suf2[i] = (calc(1, i, 0) - suf1[i] + MOD) % MOD;
		//cout << "calc i " << calc(1, i, 0) << '\n';
		for (int j = 0; j <= LEN - i; j++) {
			add(total[i], (ll)C(j, LEN - i) * ((1ll << j) % MOD) % MOD);
		}
		//cout << "suf1 suf2 total i " << suf1[i] << ' ' << suf2[i] << ' ' << total[i] << ' ' << i << '\n';
	}
	int P1 = 1, P2 = 0, res = 0;
	for (int i = 0; i < LEN; i++) {
		for (int j = 0; j <= vr[i]; j++) {
			int p1 = P1, p2 = P2;
			int s0 = 0, s1 = 0, s2 = 0;
			if (j == 0 && vl[i] == 0) {
				s1 = 1;
			}
			if (j == 0 && vl[i] == 1) {
				s0 = 1;
			}
			if (j == 1 && vl[i] == 0) {
				s1 = 1;
				s2 = 1;
			}
			if (j == 1 && vl[i] == 1) {
				s0 = 1;
				s1 = 1;
			}
			p1 = (ll)p1 * s1 % MOD;
			p2 = ((ll)p2 * (s0 + s1 + s2) + (ll)p1 * s2) % MOD;
			if (i == LEN - 1) {
				add(res, p1);
				add(res, p2);
			}	else {
				if (j < vr[i]) {
					add(res, (ll)p1 * suf1[i + 1] % MOD);
					add(res, ((ll)p2 * total[i + 1] + (ll)p1 * suf2[i + 1]) % MOD);
				}	else {
					P1 = p1, P2 = p2;
				}
			}
		}
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	fact[0] = rev[0] = 1;
	for (int i = 1; i <= K; i++) {
		fact[i] = (ll)fact[i - 1] * i % MOD;
		rev[i] = (ll)rev[i - 1] * bp(i, MOD - 2) % MOD;
	}
	cin >> L >> R;
	int res = 0;
	if (L == 1) {
		res = 1;
	}
	int fL = f(L), fR = f(R);
	for (int i = fL; i <= fR; i++) {
		l = 0, r = (1ll << i) - 1;
		if (i == fL) {
			l = L ^ (1ll << fL);
		}
		if (i == fR) {
			r = R ^ (1ll << fR);
		}
		LEN = i;
		add(res, solve());
	}
	cout << res;
}


Measured memory_bytes: 256