#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:16000000")
#pragma warning(disable : 4996)
const int inf = 1 << 25;
const double eps = 1e-9;
struct Matrix {
  static const int mod = 1000000007;
  static const int N = 8;
  int a[N][N];
  Matrix() { memset((a), (0), sizeof(a)); }
  Matrix& I() {
    memset((a), (0), sizeof(a));
    for (int i = (0); i < (N); ++i) a[i][i] = 1;
    return *this;
  }
  Matrix operator+(const Matrix& A) const {
    Matrix ret;
    for (int i = (0); i < (N); ++i)
      for (int j = (0); j < (N); ++j) ret(i, j) = (a[i][j] + A(i, j)) % mod;
    return ret;
  }
  Matrix operator*(const Matrix& A) const {
    Matrix ret;
    for (int k = (0); k < (N); ++k)
      for (int i = (0); i < (N); ++i)
        for (int j = (0); j < (N); ++j)
          ret(i, j) = (ret(i, j) + (long long)(a[i][k]) * A(k, j)) % mod;
    return ret;
  }
  Matrix operator^(int n) const {
    Matrix ret;
    ret.I();
    Matrix A(*this);
    while (n) {
      if (n & 1) ret = ret * A;
      A = A * A;
      n >>= 1;
    }
    return ret;
  }
  int sum() const {
    int ret = 0;
    for (int i = (0); i < (N); ++i)
      for (int j = (0); j < (N); ++j) ret = (ret + a[i][j]) % mod;
    return ret;
  }
  int& operator()(int i, int j) { return a[i][j]; }
  const int& operator()(int i, int j) const { return a[i][j]; }
};
Matrix calcGeom(const Matrix& A, int n) {
  Matrix ret;
  if (n == 0) return ret.I();
  if (n % 2 == 0) ret = A ^ n, n--;
  int mid = (n + 1) / 2;
  return ret + (Matrix().I() + (A ^ mid)) * calcGeom(A, mid - 1);
}
int g(const Matrix& A, int L, int R) {
  int ret = 0;
  if (L < 1) throw 0;
  if (L < 2) ++L, ret = 4;
  if (L > R) return ret;
  L -= 2, R -= 2;
  Matrix X = (A ^ L) * calcGeom(A, R - L);
  return (ret + X.sum()) % Matrix::mod;
}
long long fastPow(long long a, long long n, long long mod) {
  long long ret = 1;
  while (n > 0) {
    if (n & 1) ret *= a, ret %= mod;
    a *= a, a %= mod;
    n >>= 1;
  }
  return ret % mod;
}
int f(const Matrix& A, int L, int R) {
  if (L == 1 && R == 1) return 4;
  int ans = 0;
  if (L == 1) ++L, ans = 4;
  int all = g(A, L, R);
  if (L % 2 == 0) ++L;
  if (R % 2 == 0) --R;
  int pals = L <= R ? g(A, (L + 1) / 2, (R + 1) / 2) : 0;
  ans += ((long long)all + pals) % Matrix::mod *
         fastPow(2, Matrix::mod - 2, Matrix::mod) % Matrix::mod;
  ans += Matrix::mod;
  ans %= Matrix::mod;
  return ans;
}
enum COLOR { WHITE, BLACK, RED, YELLOW };
bool allowed[4][4];
int main() {
  int L, R;
  cin >> L >> R;
  Matrix A;
  memset((allowed), (true), sizeof(allowed));
  for (int i = (0); i < (4); ++i) allowed[i][i] = false;
  allowed[WHITE][YELLOW] = allowed[YELLOW][WHITE] = false;
  allowed[RED][BLACK] = allowed[BLACK][RED] = false;
  int row = -1;
  for (int a = (0); a < (4); ++a)
    for (int b = (0); b < (4); ++b)
      if (allowed[a][b]) {
        ++row;
        int col = -1;
        for (int c = (0); c < (4); ++c)
          for (int d = (0); d < (4); ++d)
            if (allowed[c][d]) {
              ++col;
              if (d != a) continue;
              if (d == WHITE &&
                  (c == BLACK && b == RED || c == RED && b == BLACK))
                continue;
              A(row, col) = 1;
            }
      }
  int z = 0;
  cout << f(A, L, R) << endl;
  return 0;
}
