#include <bits/stdc++.h>
using namespace std;
const int modulo = 1000000007;
int mat[17][17], res[17][17], tmp[17][17];
void multiply(int a[][17], int b[][17], int c[][17]) {
  for (int i = 0; i < 17; i++)
    for (int j = 0; j < 17; j++) c[i][j] = 0;
  for (int i = 0; i < 17; i++)
    for (int j = 0; j < 17; j++) {
      if (a[i][j] == 0) continue;
      for (int k = 0; k < 17; k++) {
        if (b[j][k] == 0) continue;
        c[i][k] = (int)((c[i][k] + (long long)a[i][j] * b[j][k]) % modulo);
      }
    }
}
void getPower(int p) {
  if (p == 0) return;
  getPower(p / 2);
  memcpy(tmp, res, sizeof(res));
  multiply(tmp, tmp, res);
  if (p % 2 == 1) {
    memcpy(tmp, res, sizeof(res));
    multiply(tmp, mat, res);
  }
}
int calc1(int x) {
  if (x < 2) return 0;
  memset(res, 0, sizeof(res));
  for (int i = 0; i < 17; i++) res[i][i] = 1;
  getPower(x - 1);
  int sum = 0;
  for (int i = 0; i < 16; i++) {
    int t1 = i / 4, t2 = i % 4;
    if (t1 == t2) continue;
    if (t1 == 0 && t2 == 3 || t1 == 3 && t2 == 0) continue;
    if (t1 == 1 && t2 == 2 || t1 == 2 && t2 == 1) continue;
    sum = (sum + res[i][16]) % modulo;
  }
  return sum;
}
int calc2(int x) {
  if (x == 0) return 0;
  if (x == 1) return 4;
  int ans = (calc1(x) + calc1((x + 1) / 2)) % modulo;
  ans = (int)((long long)ans * 500000004 % modulo);
  return (ans + 4) % modulo;
}
int main() {
  memset(mat, 0, sizeof(mat));
  for (int i = 0; i < 16; i++) {
    int t1 = i / 4, t2 = i % 4;
    if (t1 == t2) continue;
    if (t1 == 0 && t2 == 3 || t1 == 3 && t2 == 0) continue;
    if (t1 == 1 && t2 == 2 || t1 == 2 && t2 == 1) continue;
    for (int j = 0; j < 4; j++) {
      if (t2 == j) continue;
      if (t2 == 0 && j == 3 || t2 == 3 && j == 0) continue;
      if (t2 == 1 && j == 2 || t2 == 2 && j == 1) continue;
      if (t1 == 1 && t2 == 0 && j == 2) continue;
      if (t1 == 2 && t2 == 0 && j == 1) continue;
      mat[i][t2 * 4 + j] = 1;
    }
    mat[i][16] = 1;
  }
  mat[16][16] = 1;
  int L, R;
  scanf("%d%d", &L, &R);
  printf("%d\n", (calc2(R) - calc2(L - 1) + modulo) % modulo);
  return 0;
}
