#include <bits/stdc++.h>
using namespace std;
const int moder = int(1e9) + 7;
int add(int a, int b) {
  long long c = 0ll + a + b;
  return c < moder ? c : c - moder;
}
int mul(int a, int b) {
  long long c = 1ll * a * b;
  return c % moder;
}
struct Matrix {
  int v[20][20];
  Matrix() {}
  Matrix operator*(const Matrix& b) const {
    Matrix R;
    for (int i = 0; i <= 16; i++)
      for (int j = 0; j <= 16; j++) {
        int sum = 0;
        for (int k = 0; k <= 16; k++) sum = add(sum, mul(v[i][k], b.v[k][j]));
        R.v[i][j] = sum;
      }
    return R;
  }
  void print() {
    for (int i = 0; i <= 16; i++) {
      for (int j = 0; j <= 16; j++) cout << v[i][j] << " ";
      cout << endl;
    }
    cout << endl;
    return;
  }
} shift;
const int maxn = int(1e5) + 11;
int n, m;
int ans[maxn];
int calc(int n) {
  if (n == 0) return 0;
  if (n == 1) return 4;
  Matrix a, b;
  memset(a.v, 0, sizeof a.v);
  for (int i = 0; i <= 16; i++) a.v[i][i] = 1;
  b = shift;
  for (int k = n - 1; k > 0; k >>= 1) {
    if (k & 1) a = a * b;
    b = b * b;
  }
  int sum = 4;
  for (int i = 0; i <= 16; i++) sum = add(sum, mul(a.v[16][i], ans[i]));
  return sum;
}
bool check(int x, int y) {
  if (x == y) return 0;
  if (x + y == 1) return 0;
  if (x + y == 5) return 0;
  return 1;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 4; j++)
      if (i != j)
        for (int k = 0; k < 4; k++)
          if (i != j && check(j, k)) {
            if (i != 3 && j != 3 && k != 3 && i + j + k == 3) continue;
            int x = i * 4 + j;
            int y = j * 4 + k;
            shift.v[y][x] = 1;
          }
  for (int i = 0; i <= 16; i++) shift.v[16][i] = 1;
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 4; j++)
      if (check(i, j)) ans[i * 4 + j] = 1;
  int res1 = calc(m) - calc(n - 1);
  if (res1 < 0) res1 += moder;
  int res2 = calc((m + 1) / 2) - calc(n / 2);
  if (res2 < 0) res2 += moder;
  int res = mul(add(res1, res2), (moder + 1) / 2);
  printf("%d\n", res);
  return 0;
}
