#include <bits/stdc++.h>
using namespace std;
struct mat {
  long long first[17][17];
  void init() { memset(first, 0, sizeof(first)); }
  mat operator*(const mat &a) const {
    mat c;
    c.init();
    for (int i = 0; i < 17; i++)
      for (int j = 0; j < 17; j++)
        for (int k = 0; k < 17; k++)
          c.first[i][j] =
              (c.first[i][j] + 1LL * first[i][k] * a.first[k][j] % 1000000007) %
              1000000007;
    return c;
  }
};
bool bad(int i, int j) {
  if (i == j) return 1;
  if (i + j == 3) return 1;
  return 0;
}
long long div2(long long n) {
  while (n < 0) n += 1000000007;
  n %= 1000000007;
  if (n & 1) n += 1000000007;
  return n / 2;
}
long long cal(long long n) {
  if (n == 0) return 0;
  if (n == 1) return 4;
  n--;
  mat a, b;
  a.init();
  b.init();
  int q[17];
  memset(q, 0, sizeof(q));
  q[16] = 4;
  int i, j, k;
  for (i = 0; i < 17; i++) b.first[i][i] = 1, a.first[16][i] = 1;
  for (i = 0; i < 4; i++)
    for (j = 0; j < 4; j++) {
      if (bad(i, j)) continue;
      q[i * 4 + j] = 1;
      for (k = 0; k < 4; k++) {
        if (bad(j, k) || (i + j + k == 3)) continue;
        a.first[i * 4 + j][j * 4 + k] = 1;
      }
    }
  for (; n > 0;) {
    if (n & 1)
      b = b * a, n--;
    else
      a = a * a, n >>= 1;
  }
  long long ans = 0;
  for (i = 0; i < 17; i++) {
    ans = (ans + 1LL * b.first[16][i] * q[i] % 1000000007) % 1000000007;
  }
  return ans;
}
int main() {
  int i, j, n, m, k;
  long long l, r;
  while (cin >> l >> r) {
    long long ans = cal(r) - cal(l - 1);
    if (ans < 0) ans += 1000000007;
    r += r & 1;
    l--;
    l += l & 1;
    long long val = cal(r / 2) - cal(l / 2);
    ans = (div2(ans - val) + val + 1000000007) % 1000000007;
    printf("%I64d\n", ans);
  }
  return 0;
}
