#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
const int mod = 1000000000 + 7;
int n;
int m;
int g[17][17];
int e[17][17];
int z[17][17];
int forb(int a, int b) {
  if (a == b || a == 0 && b == 1 || a == 1 && b == 0 || a == 2 && b == 3 ||
      a == 3 && b == 2)
    return 1;
  return 0;
}
int forb(int a, int b, int c) {
  if (a == 3 && b == 0 && c == 2 || a == 2 && b == 0 && c == 3) return 1;
  return 0;
}
int power(int x, int y) {
  int z = 1;
  while (y) {
    if (y & 1) z = ((long long)z * x) % mod;
    x = ((long long)x * x) % mod;
    y /= 2;
  }
  return z;
}
int go(int x, int t) {
  if (x == 0) return 0;
  int ans = 3;
  if (t) (ans += go((x + 1) / 2, 0)) %= mod;
  memset(g, 0, sizeof(g));
  for (int a = 0; a < 4; a++)
    for (int b = 0; b < 4; b++)
      if (!forb(a, b)) {
        g[a * 4 + b][16] = 1;
        for (int c = 0; c < 4; c++)
          if (!forb(b, c) && !forb(a, b, c)) g[a * 4 + b][b * 4 + c] = 1;
      }
  g[16][16] = 1;
  memset(e, 0, sizeof(e));
  for (int i = 0; i < 17; i++) e[i][i] = 1;
  x--;
  while (x) {
    if (x & 1) {
      for (int i = 0; i < 17; i++)
        for (int j = 0; j < 17; j++) {
          z[i][j] = 0;
          for (int k = 0; k < 17; k++)
            z[i][j] = (z[i][j] + (long long)e[i][k] * g[k][j]) % mod;
        }
      for (int i = 0; i < 17; i++)
        for (int j = 0; j < 17; j++) e[i][j] = z[i][j];
    }
    x /= 2;
    for (int i = 0; i < 17; i++)
      for (int j = 0; j < 17; j++) {
        z[i][j] = 0;
        for (int k = 0; k < 17; k++)
          z[i][j] = (z[i][j] + (long long)g[i][k] * g[k][j]) % mod;
      }
    for (int i = 0; i < 17; i++)
      for (int j = 0; j < 17; j++) g[i][j] = z[i][j];
  }
  for (int i = 0; i < 17; i++) (ans += e[i][16]) %= mod;
  if (t) ans = ((long long)ans * power(2, mod - 2)) % mod;
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  printf("%d\n", (go(m, 1) - go(n - 1, 1) + mod) % mod);
  return 0;
}
