#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > mul(vector<vector<long long> > a,
                               vector<vector<long long> > b) {
  vector<vector<long long> > res(
      ((long long)a.size()), vector<long long>(((long long)b[0].size()), 0));
  for (long long i = 0; i < ((long long)((long long)a.size())); i++)
    for (long long j = 0; j < ((long long)((long long)b[0].size())); j++)
      for (long long k = 0; k < ((long long)((long long)a[0].size())); k++)
        res[i][j] = (res[i][j] + a[i][k] * b[k][j]) % 1000000007;
  return res;
}
vector<vector<long long> > pow(vector<vector<long long> > a, long long n) {
  vector<vector<long long> > res(
      ((long long)a.size()), vector<long long>(((long long)a[0].size()), 0));
  for (long long i = 0; i < ((long long)((long long)a.size())); i++)
    res[i][i] = 1;
  while (n) {
    if (n % 2) res = mul(res, a);
    a = mul(a, a);
    n /= 2;
  }
  return res;
}
bool bad(int i, int j) {
  if ((i == 0 || i == 3) && (j == 0 || j == 3)) return true;
  if ((i == 1 || i == 2) && (j == 1 || j == 2)) return true;
  return false;
}
bool bad(int i, int j, int k) {
  if (i == 1 && j == 0 && k == 2) return true;
  if (i == 2 && j == 0 && k == 1) return true;
  return false;
}
long long cal1(long long num) {
  vector<vector<long long> > res(32, vector<long long>(32, 0));
  vector<vector<long long> > base(32, vector<long long>(1, 0));
  for (long long i = 0; i < ((long long)4); i++)
    for (long long j = 0; j < ((long long)4); j++)
      for (long long k = 0; k < ((long long)4); k++) {
        if (bad(i, j)) continue;
        if (bad(j, k)) continue;
        if (bad(i, j, k)) continue;
        res[i * 4 + j][j * 4 + k] = 1;
      }
  for (long long i = 0; i < ((long long)4); i++)
    for (long long j = 0; j < ((long long)4); j++)
      base[i * 4 + j][0] = (bad(i, j)) ? 0 : 1;
  for (long long i = 0; i < ((long long)16); i++)
    res[i + 16][i] = res[i + 16][i + 16] = 1;
  res = pow(res, num - 1);
  res = mul(res, base);
  long long sum = 4;
  for (long long i = 0; i < ((long long)16); i++) sum += res[i + 16][0];
  return sum;
}
long long cal0(long long num) {
  if (num <= 0) return 0;
  long long a = cal1(num);
  long long b = cal1((num + 1) / 2);
  return ((a + b + 2 * 1000000007) / 2) % 1000000007;
}
int main() {
  long long low, high;
  cin >> low >> high;
  cout << (cal0(high) - cal0(low - 1) + 1000000007) % 1000000007 << endl;
}
