#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

constexpr ll mod = 1000000007;
constexpr ll modsize = 0;
vector<ll> fac(modsize);
vector<ll> inv(modsize);
vector<ll> facinv(modsize);

void modcalc() {
	if (modsize == 0) abort();
	fac[0] = 1; fac[1] = 1; inv[1] = 1;
	facinv[0] = 1; facinv[1] = 1;
	for (ll i = 2; i < modsize; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		facinv[i] = facinv[i - 1] * inv[i] % mod;
	}
}

ll modinv(ll a) {
	if (a == 0) abort();
	ll b = mod, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}

ll modpow(ll a, ll b) {
	ll ans = 1;
	a %= mod;
	while (b) {
		if (b & 1) ans = ans * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return ans;
}

ll modcomb(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return fac[n] * facinv[k] % mod * facinv[n - k] % mod;
}

ll modperm(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return fac[n] * facinv[n - k] % mod;
}

ll modhom(ll n, ll k) {
	if (n < 0 || k < 0 || n == 0 && k > 0) return 0;
	if (n == 0 && k == 0) return 1;
	return fac[n + k - 1] * facinv[k] % mod * facinv[n - 1] % mod;
}

ll solve(ll l, ll r) {
	if (l > r) return 0;
	ll ans = 0;
	ll st = 1;
	while (st < l) st <<= 1;
	ll prev = st;
	bool flag = false; ll coeff = 1;
	while (st <= r) {
		for (ll i = prev; i >= 1; (i >>= 1)) {
			if (st + i <= r + 1) {
				if (flag) {
					coeff *= 2; coeff %= mod; prev = i;
				}
				else prev <<= 1;
				if (i != st) flag = true;
				ll tmp = i; ll cnt = 0;
				while (tmp > 1) {
					tmp >>= 1; cnt++;
				}
				ans += modpow(3, cnt)*coeff % mod;
				if (ans >= mod) ans -= mod;
				st += i;
				break;
			}
		}
	}
	return ans;
}

ll solve2(ll l, ll r) {
	if (l > r) return 0;
	ll ans = solve(l, r);
	ll st = 1; ll cnt = 1;
	while (st < l) st <<= 1;
	ans += solve(st / 2, 3 * st / 2 - 1 - l);
	return ans;
}

ll solve3(ll l, ll r) {
	if (l > r) return 0;
	if (l == r) return 1;
	while (true) {
		ll check = 0;
		bool ok = false;
		for (ll i = 1; i < INF * 2; (i <<= 1)) {
			if (i <= l && r < (i << 1)) {
				ok = true;
				check = i;
			}
		}
		l -= check; r -= check;
		if (!ok) break;
	}
	ll mi;
	for (ll i = 1; i < INF * 2; (i <<= 1)) {
		if (l < i&&i <= r) {
			mi = i;
		}
	}
	return (solve3(l, mi - 1) + solve3(mi, r) + solve3(l, r - mi)) % mod;
}

ll solve4(ll l, ll r) {
	if (l > r) return 0;
	for (ll i = 1; i < INF * 2; (i <<= 1)) {
		if (i < l && r < (i << 1)) {
			return solve3(l, r);
		}
	}
	return solve2(l, r);
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	ll l, r;
	cin >> l >> r;
	cout << solve4(l, r) % mod << '\n';
}

Measured memory_bytes: 256