#include <bits/stdc++.h>
using namespace std;
long long l, r, mod = 1e9 + 7;
long long binpow(long long x, long long y) {
  long long ans = 1;
  while (y) {
    if (y & 1) ans = (ans * x) % mod;
    x = (x * x) % mod;
    y >>= 1;
  }
  return ans;
}
long long g(long long x) {
  if (x == 0) return 0;
  if (x == 1) return 4;
  if (x == 2) return 8;
  if (x == 3) return 19;
  long long k = x / 4;
  long long temp1 = binpow(3, k - 1), temp2 = (binpow(9, k - 1) * 3) % mod,
            temp3 = (temp1 + temp2) % mod;
  (temp3 & 1) ? temp3 = (temp3 + mod) / 2 : temp3 = temp3 / 2;
  long long ans0 = (19 * temp3 - 7 + mod) % mod;
  long long ans1 = (ans0 + (7 * (binpow(3, 2 * k - 1))) % mod +
                    (7 * binpow(3, k - 1)) % mod) %
                   mod;
  long long ans2 = (ans1 + (4 * binpow(3, 2 * k)) % mod) % mod;
  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;
}
