#include <bits/stdc++.h>
const int MATRIXSIZE = 2;
const long long MODULO = 1000000007;
class Vect {
 public:
  Vect(long long* vals = NULL);
  long long& operator[](int);
  const long long& operator[](int) const;
  long long val[MATRIXSIZE];
};
Vect::Vect(long long* vals) {
  for (int i = 0; i < MATRIXSIZE; i++)
    vals == NULL ? val[i] = 0 : val[i] = vals[i] % MODULO;
}
long long& Vect::operator[](int pos) { return val[pos]; }
const long long& Vect::operator[](int pos) const { return val[pos]; }
class Matrix {
 public:
  Matrix(long long init = 1);
  long long* operator[](int);
  Matrix& operator+=(const Matrix&);
  Matrix operator+(const Matrix&) const;
  Matrix& operator-=(const Matrix&);
  Matrix operator-(const Matrix&) const;
  Matrix operator*(const Matrix&) const;
  Vect operator*(const Vect&) const;
  Matrix& operator*=(const long long&);
  Matrix operator*(const long long&) const;
  Matrix operator^(int) const;
  Matrix powerSum(int n) const;
  long long table[MATRIXSIZE][MATRIXSIZE];
};
Matrix::Matrix(long long init) {
  init %= MODULO;
  for (int i = 0; i < MATRIXSIZE; i++)
    for (int j = 0; j < MATRIXSIZE; j++)
      i == j ? table[i][j] = init : table[i][j] = 0;
}
long long* Matrix::operator[](int row) { return table[row]; }
Matrix& Matrix::operator+=(const Matrix& a) {
  for (int i = 0; i < MATRIXSIZE; i++)
    for (int j = 0; j < MATRIXSIZE; j++)
      table[i][j] += a.table[i][j], table[i][j] %= MODULO;
  return *this;
}
Matrix Matrix::operator+(const Matrix& a) const {
  Matrix ret(*this);
  return ret += a;
}
Matrix& Matrix::operator-=(const Matrix& a) {
  for (int i = 0; i < MATRIXSIZE; i++)
    for (int j = 0; j < MATRIXSIZE; j++)
      table[i][j] = (table[i][j] + MODULO - a.table[i][j]) % MODULO;
  return *this;
}
Matrix Matrix::operator*(const Matrix& a) const {
  Matrix ret(0);
  for (int i = 0; i < MATRIXSIZE; i++)
    for (int j = 0; j < MATRIXSIZE; j++)
      for (int t = 0; t < MATRIXSIZE; t++)
        ret.table[i][j] += table[i][t] * a.table[t][j] % MODULO,
            ret.table[i][j] %= MODULO;
  return ret;
}
Vect Matrix::operator*(const Vect& a) const {
  Vect ret;
  for (int i = 0; i < MATRIXSIZE; i++)
    for (int j = 0; j < MATRIXSIZE; j++)
      ret[i] += table[i][j] * a.val[j] % MODULO, ret[i] %= MODULO;
  return ret;
}
Matrix& Matrix::operator*=(const long long& a) {
  for (int i = 0; i < MATRIXSIZE; i++)
    for (int j = 0; j < MATRIXSIZE; j++)
      table[i][j] *= a, table[i][j] %= MODULO;
  return *this;
}
Matrix Matrix::operator*(const long long& a) const {
  Matrix ret(*this);
  return ret *= a;
}
Matrix Matrix::operator^(int exp) const {
  Matrix ret, a(*this);
  while (exp) {
    if (exp & 1) ret = ret * a;
    a = a * a, exp >>= 1;
  }
  return ret;
}
Matrix Matrix::powerSum(int n) const {
  Matrix ret(0), temp, A(*this), I;
  while (n) {
    if (n & 1) ret = ret * A, ret += temp;
    temp = temp * (I + A), A = A * A, n >>= 1;
  }
  return ret;
}
Matrix A(0), SUM;
Vect sec, sol;
long long getS(int L, int R) {
  if (L > R) return 0;
  long long ret = 0;
  ret = 0;
  if (L == 1) ret = 4, L = 2;
  SUM = A ^ (L - 2), R -= L;
  SUM = SUM * A.powerSum(R + 1);
  sol = SUM * sec;
  ret += 2 * sol[0] + 4 * sol[1];
  return ret % MODULO;
}
int main() {
  int L, R;
  long long ret;
  A[0][1] = 3, A[1][0] = 1;
  ;
  sec[0] = 2, sec[1] = 1;
  while (scanf("%d %d", &L, &R) != EOF) {
    ret = getS(L, R);
    if ((L & 1) == 0) L++;
    L++, R++, L /= 2, R /= 2;
    ret += getS(L, R);
    ret %= MODULO;
    if (ret & 1)
      ret = (ret + MODULO) / 2;
    else
      ret /= 2;
    printf("%lld\n", ret);
  }
  return 0;
}
