#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, e, f[105], g, h, i, j, k;
struct node {
  long long x[20][20];
  friend struct node operator*(const node &xx, const node &yy) {
    struct node kkk;
    memset(kkk.x, 0, sizeof(kkk.x));
    for (long long iii = 1; iii <= 17; iii++)
      for (long long jjj = 1; jjj <= 17; jjj++)
        for (long long kkkk = 1; kkkk <= 17; kkkk++) {
          kkk.x[iii][jjj] += xx.x[iii][kkkk] * yy.x[kkkk][jjj];
          kkk.x[iii][jjj] %= 1000000007;
        }
    return kkk;
  }
};
struct node ch;
struct node F;
struct node G;
struct node root;
long long v[10][10];
long long an;
long long in(long long x, long long y) { return (x - 1) * 4 + y; }
long long MOD(long long x) {
  if (x < 0) x += 1000000007 * ((-x) / 1000000007 + 1);
  x %= 1000000007;
  return x;
}
struct node Mi(long long x) {
  struct node u, w;
  u = ch;
  if (x == 0) return ch;
  if (x == 1) return root;
  w = Mi(x >> 1);
  w = w * w;
  if (x & 1) w = w * root;
  return w;
}
long long An(long long x) {
  long long ii, jj, kk;
  kk = 0;
  if (x == 0) return 0;
  if (x == 1) return 0;
  F = Mi(x - 1);
  for (ii = 1; ii <= 17; ii++) {
    kk += f[ii] * F.x[ii][17];
    kk = MOD(kk);
  }
  x = (x + 1) >> 1;
  F = Mi(x - 1);
  for (ii = 1; ii <= 17; ii++) {
    kk += f[ii] * F.x[ii][17];
    kk = MOD(kk);
  }
  return kk;
}
long long check(long long x, long long y, long long z) {
  if (x == 2 && y == 1 && z == 3) return 0;
  if (x == 3 && y == 1 && z == 2) return 0;
  if (x == y || y == z) return 0;
  return 1;
}
void Make_Matrix() {
  long long ii, jj, kk;
  v[1][4] = 1;
  v[4][1] = 1;
  v[2][3] = 1;
  v[3][2] = 1;
  for (ii = 1; ii <= 4; ii++) v[ii][ii] = 1;
  for (ii = 1; ii <= 4; ii++)
    for (jj = 1; jj <= 4; jj++)
      for (kk = 1; kk <= 4; kk++)
        if (check(ii, jj, kk) && v[jj][kk] == 0)
          root.x[in(ii, jj)][in(jj, kk)] = 1;
  for (ii = 1; ii <= 17; ii++) root.x[ii][17] = 1;
  for (ii = 1; ii <= 4; ii++)
    for (jj = 1; jj <= 4; jj++) f[in(ii, jj)] = v[ii][jj] ^ 1;
  f[17] = 0;
}
int main() {
  scanf("%I64d%I64d", &a, &b);
  Make_Matrix();
  if (b != 1) an = An(b);
  an += 8;
  if (a != 2) an -= An(a - 1);
  if (a != 1) an -= 8;
  an = MOD(an);
  if (an & 1) an += 1000000007;
  an >>= 1;
  printf("%I64d\n", an);
  return 0;
}
