#include <bits/stdc++.h>
using namespace std;
unsigned long long bigMod(unsigned long long a, unsigned long long b,
                          unsigned long long c) {
  if (a == 0 || b == 0) {
    return 0;
  }
  if (a == 1) {
    return b;
  }
  if (b == 1) {
    return a;
  }
  unsigned long long a2 = bigMod(a, b / 2LLU, c);
  if ((b & 1) == 0) {
    return (a2 + a2) % c;
  } else {
    return ((a % c) + (a2 + a2)) % c;
  }
}
unsigned long long odd_sum_part(unsigned long long P) {
  return bigMod(P, P, 1000000007LLU);
}
unsigned long long odd_sum(unsigned long long A, unsigned long long B) {
  unsigned long long F = odd_sum_part(A - 1LLU);
  unsigned long long S = odd_sum_part(B);
  unsigned long long ans = (S - F + 1000000007LLU) % 1000000007LLU;
  return ans;
}
unsigned long long even_sum_part(unsigned long long P) {
  return bigMod(P, P + 1LLU, 1000000007LLU);
}
unsigned long long even_sum(unsigned long long A, unsigned long long B) {
  unsigned long long F = even_sum_part(A - 1LLU);
  unsigned long long S = even_sum_part(B);
  unsigned long long ans = (S - F + 1000000007LLU) % 1000000007LLU;
  return ans;
}
unsigned long long sum(unsigned long long P) {
  unsigned long long total_sum = 0LL;
  unsigned long long cur = 0LL, odd_num = 1LL, even_num = 1LL;
  for (int b = 0; cur < P; b++) {
    if (!(b % 2LLU)) {
      if (cur + (1LLU << b) <= P) {
        total_sum =
            (total_sum + odd_sum(odd_num, odd_num + (1LLU << b) - 1LLU)) %
            1000000007LLU;
        odd_num += (1LLU << b);
      } else {
        total_sum = (total_sum + odd_sum(odd_num, odd_num + P - cur - 1LLU)) %
                    1000000007LLU;
        break;
      }
    } else {
      if (cur + (1LLU << b) <= P) {
        total_sum =
            (total_sum + even_sum(even_num, even_num + (1LLU << b) - 1LLU)) %
            1000000007LLU;
        even_num += (1LLU << b);
      } else {
        total_sum =
            (total_sum + even_sum(even_num, even_num + P - cur - 1LLU)) %
            1000000007LLU;
        break;
      }
    }
    cur += (1LLU << b);
    if (cur >= P) break;
  }
  return total_sum;
}
int main(void) {
  unsigned long long L, R;
  cin >> L >> R;
  unsigned long long A = sum(L - 1LLU);
  unsigned long long B = sum(R);
  unsigned long long ans = (B - A + 1000000007LLU) % 1000000007LLU;
  printf("%llu\n", ans);
  return 0;
}
