#include <bits/stdc++.h>
using namespace std;
template <class T>
void print(vector<T> s) {
  for (T x : s) cout << x << " ";
  cout << endl;
}
mt19937 mrand(random_device{}());
int rnd() { return mrand(); }
const int mod = 1e9 + 7;
vector<int> getBits(long long x) {
  vector<int> a;
  while (x > 0) {
    a.push_back(x & 1);
    x >>= 1;
  }
  reverse(a.begin(), a.end());
  return a;
}
long long calc(vector<int> curL, vector<int> curR, int n) {
  for (int k = 0; k < min(curL.size(), curR.size()); k++) {
    if (curL[k] > curR[k]) return 0;
  }
  long long answer = 1;
  for (int i = curL.size(); i < curR.size(); i++) {
    if (curR[i] == 1) answer = answer * 2 % mod;
  }
  for (int i = curR.size(); i < curL.size(); i++) {
    if (curL[i] == 0) answer = answer * 2 % mod;
  }
  for (int i = max(curL.size(), curR.size()); i < n; i++)
    answer = answer * 3 % mod;
  return answer;
}
long long get(long long l, long long r) {
  if (l > r) return 0;
  vector<int> L = getBits(l);
  vector<int> R = getBits(r);
  assert(L.size() == R.size());
  int n = L.size();
  int cur = 0;
  while (cur < n && L[cur] == R[cur]) cur++;
  vector<int> curL;
  long long result = 0;
  for (int i = cur; i < n + 1; i++) {
    if (i > cur) curL.push_back(L[i - 1]);
    if (i < n && L[i] == 1) continue;
    if (i < n) curL.push_back(1);
    vector<int> curR;
    for (int j = cur; j < n + 1; j++) {
      if (j > cur) curR.push_back(R[j - 1]);
      if (j < n && R[j] == 0) continue;
      if (j < n) curR.push_back(0);
      result += calc(curL, curR, n - cur);
      curR.pop_back();
    }
    curL.pop_back();
  }
  return result % mod;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.precision(77);
  long long l, r;
  cin >> l >> r;
  long long answer = 0;
  for (int i = 0; i < 61; i++)
    answer += get(max(l, (1LL << i)), min(r, (1LL << (i + 1)) - 1));
  cout << answer % mod << endl;
  return 0;
}
