#include <bits/stdc++.h>
using namespace std;
unsigned long long l, r, mod = 1e9 + 7;
unsigned long long binpow(unsigned long long x, unsigned long long y) {
  unsigned long long ans = 1;
  while (y) {
    if (y & 1) ans = (ans * x) % mod;
    x = (x * x) % mod;
    y >>= 1;
  }
  return ans;
}
unsigned long long g(unsigned long long x) {
  if (x == 0) return 0;
  if (x == 1) return 4;
  if (x == 2) return 8;
  if (x == 3) return 19;
  if (x == 4) return 31;
  unsigned long long k = x / 4;
  unsigned long long temp1 = binpow(3, k - 1), temp2 = binpow(9, k - 1);
  temp2 = (temp2 * 3) % mod;
  unsigned long long temp3 = (temp1 + temp2) % mod;
  if (temp3 & 1)
    temp3 = (temp3 + mod) / 2;
  else
    temp3 = temp3 / 2;
  unsigned long long ans0 = (19 * temp3 - 7 + mod) % mod;
  unsigned long long ans1 = (ans0 + (7 * (binpow(3, 2 * k - 1))) % mod +
                             (7 * binpow(3, k - 1)) % mod) %
                            mod;
  unsigned long long ans2 = (ans1 + (4 * binpow(3, 2 * k)) % mod) % mod;
  unsigned long long ans3 =
      (ans2 +
       ((7 * binpow(3, 2 * k)) % mod + (4 * (binpow(3, k))) % mod) % mod) %
      mod;
  if (x % 4 == 0) return ans0;
  if (x % 4 == 1) return ans1;
  if (x % 4 == 2) return ans2;
  if (x % 4 == 3) return ans3;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> l >> r;
  cout << (g(r) - g(l - 1) + mod) % mod;
}
