#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long f[] = {0, 4, 4, 11, 12};
inline long long modPow(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) (ret *= a) %= mod;
    (a *= a) %= mod;
    b >>= 1;
  }
  return ret;
}
inline long long sumOdd(long long l, long long r) {
  return 7 * (modPow(3, r) + mod - modPow(3, l - 1)) % mod;
}
inline long long sumEven(long long l, long long r) {
  return 4 * (modPow(3, r + 1) + mod - modPow(3, l)) % mod;
}
inline long long func(long long l, long long r, bool flg) {
  long long ret = 0;
  if (l > r) return ret;
  {
    long long lo = l / 2;
    long long hi = (r - 1) / 2;
    if (lo <= hi) {
      ret += sumOdd(lo, hi);
      if (flg) ret += func(lo + 1, hi + 1, false);
    }
  }
  {
    long long lo = (l - 1) / 2;
    long long hi = (r - 2) / 2;
    if (lo <= hi) {
      ret += sumEven(lo, hi);
    }
  }
  ret %= mod;
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout << setprecision(32);
  int l, r;
  cin >> l >> r;
  long long ans = 0;
  while (l <= r && l <= 4) {
    ans += f[l];
    l++;
  }
  if (l <= r) ans += func(l, r, true) * ((mod + 1) / 2);
  ans %= mod;
  cout << ans << endl;
  return 0;
}
