#include <bits/stdc++.h>
using namespace std;
vector<vector<long long int> > mul(vector<vector<long long int> > a,
                                   vector<vector<long long int> > b) {
  vector<vector<long long int> > res(
      ((long long int)a.size()),
      vector<long long int>(((long long int)b[0].size()), 0));
  for (long long int i = 0; i < ((long long int)(((long long int)a.size())));
       i++)
    for (long long int j = 0;
         j < ((long long int)(((long long int)b[0].size()))); j++)
      for (long long int k = 0;
           k < ((long long int)(((long long int)a[0].size()))); k++)
        res[i][j] = (res[i][j] + a[i][k] * b[k][j]) % 1000000007ll;
  return res;
}
vector<vector<long long int> > pow(vector<vector<long long int> > a,
                                   long long int n) {
  vector<vector<long long int> > res(
      ((long long int)a.size()),
      vector<long long int>(((long long int)a[0].size()), 0));
  for (long long int i = 0; i < ((long long int)(((long long int)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 bad2(long long int c0, long long int c1) {
  if (c0 == c1) return true;
  if (c0 + c1 == 3) return true;
  return false;
}
bool bad3(long long int c0, long long int c1, long long int c2) {
  if (c0 == 1 && c1 == 0 && c2 == 2) return true;
  if (c0 == 2 && c1 == 0 && c2 == 1) return true;
  return false;
}
long long int cal(long long int length) {
  if (length <= 0) return 0;
  vector<vector<long long int> > base(32, vector<long long int>(32, 0));
  for (long long int i = 0; i < ((long long int)(16)); i++)
    base[i + 16][i] = base[i + 16][i + 16] = 1;
  for (long long int i = 0; i < ((long long int)(4)); i++)
    for (long long int j = 0; j < ((long long int)(4)); j++)
      for (long long int k = 0; k < ((long long int)(4)); k++) {
        if (bad2(i, j)) continue;
        if (bad2(j, k)) continue;
        if (bad3(i, j, k)) continue;
        base[k * 4 + j][j * 4 + i] = 1;
      }
  vector<vector<long long int> > start(32, vector<long long int>(1, 0));
  for (long long int i = 0; i < ((long long int)(4)); i++)
    for (long long int j = 0; j < ((long long int)(4)); j++) {
      if (bad2(i, j)) continue;
      start[j * 4 + i][0] = 1;
    }
  base = pow(base, length - 1);
  start = mul(base, start);
  long long int res = 4;
  for (long long int i = 0; i < ((long long int)(16)); i++)
    res = (res + start[i + 16][0]) % 1000000007ll;
  return res;
}
long long int cal0(long long int length) {
  if (length <= 0) return 0;
  return ((cal(length) + cal((length + 1) / 2)) * (1000000007ll / 2 + 1)) %
         1000000007ll;
}
int main() {
  long long int low, high;
  cin >> low >> high;
  cout << ((cal0(high) - cal0(low - 1)) % 1000000007ll + 1000000007ll) %
              1000000007ll
       << endl;
}
