#include <bits/stdc++.h>
using namespace std;
const long long modn = 1000000007;
long long g[20][20], f[20], tmpf[20], tmpg[20][20];
long long mat[20][20], ff[20];
long long l, r, cnt[20];
long long mul(long long p, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * p % modn;
    p = p * p % modn;
    n >>= 1;
  }
  return res;
}
void mulf() {
  memset(tmpf, 0, sizeof(tmpf));
  for (long long j = 0; j <= 16; ++j)
    for (long long k = 0; k <= 16; ++k)
      tmpf[j] = (tmpf[j] + f[k] * g[k][j]) % modn;
  memcpy(f, tmpf, sizeof(f));
}
void mulg() {
  memset(tmpg, 0, sizeof(tmpg));
  for (long long i = 0; i <= 16; ++i)
    for (long long j = 0; j <= 16; ++j)
      for (long long k = 0; k <= 16; ++k)
        tmpg[i][j] = (tmpg[i][j] + g[i][k] * g[k][j]) % modn;
  memcpy(g, tmpg, sizeof(g));
}
long long work(long long p) {
  memcpy(g, mat, sizeof(mat));
  memcpy(f, ff, sizeof(f));
  p--;
  while (p) {
    if (p & 1) mulf();
    mulg();
    p >>= 1;
  }
  return f[16];
}
long long solve(long long r) {
  if (r == 0) return 0;
  long long res = work(r);
  long long tmp = work(r / 2 + r % 2);
  tmp = (res - tmp + modn) % modn;
  long long temp = mul(2, modn - 2);
  tmp = tmp * temp % modn;
  res = (res - tmp + modn) % modn;
  return res;
}
void initmat() {
  ff[16] = 4;
  for (long long i = 0; i < 16; ++i) {
    long long a = i / 4, b = i % 4;
    if (a == b) continue;
    if (a == 3 && b == 2 || a == 2 && b == 3) continue;
    if (a == 0 && b == 1 || a == 1 && b == 0) continue;
    ff[i] = 1;
    for (long long c = 0; c < 4; ++c) {
      if (c == b) continue;
      if (c == 3 && b == 2 || c == 2 && b == 3) continue;
      if (c == 0 && b == 1 || c == 1 && b == 0) continue;
      if (a != c && a != 3 && b != 3 && c != 3) continue;
      mat[i][b * 4 + c] = 1;
    }
  }
  for (long long i = 0; i <= 16; ++i) mat[i][16] = 1;
}
int main() {
  initmat();
  scanf("%I64d%I64d", &l, &r);
  long long resa = solve(r);
  long long resb = solve(l - 1);
  resa = (resa - resb + modn) % modn;
  printf("%I64d\n", resa);
  return 0;
}
