#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > a;
vector<vector<int> > zero;
vector<vector<int> > calc2(int x) {
  int i, j, k;
  vector<vector<int> > b, c;
  if (x == 0) {
    b = zero;
    for (i = 0; i < 16; i++) b[i][i] = 1;
    return b;
  }
  if (x % 2 == 0) {
    b = calc2(x / 2);
    c = zero;
    for (i = 0; i < 16; i++)
      for (j = 0; j < 16; j++)
        for (k = 0; k < 16; k++)
          c[i][j] = (c[i][j] + (long long)b[i][k] * b[k][j]) % 1000000007;
    return c;
  } else {
    b = calc2(x / 2);
    c = zero;
    for (i = 0; i < 16; i++)
      for (j = 0; j < 16; j++)
        for (k = 0; k < 16; k++)
          c[i][j] = (c[i][j] + (long long)b[i][k] * b[k][j]) % 1000000007;
    b = zero;
    for (i = 0; i < 16; i++)
      for (j = 0; j < 16; j++)
        for (k = 0; k < 16; k++)
          b[i][j] = (b[i][j] + (long long)c[i][k] * a[k][j]) % 1000000007;
    return b;
  }
}
vector<vector<int> > calc1(int x) {
  int i, j, k;
  vector<vector<int> > b, c, d;
  if (x == 0) return zero;
  if (x == 1) {
    b = zero;
    for (i = 0; i < 16; i++) b[i][i] = 1;
    return b;
  }
  if (x % 2 == 0) {
    b = calc1(x / 2);
    c = calc2(x / 2);
    for (i = 0; i < 16; i++) {
      c[i][i]++;
      if (c[i][i] >= 1000000007) c[i][i] -= 1000000007;
    }
    d = zero;
    for (i = 0; i < 16; i++)
      for (j = 0; j < 16; j++)
        for (k = 0; k < 16; k++)
          d[i][j] = (d[i][j] + (long long)b[i][k] * c[k][j]) % 1000000007;
    return d;
  } else {
    b = calc1(x / 2);
    c = calc2(x / 2);
    for (i = 0; i < 16; i++) {
      c[i][i]++;
      if (c[i][i] >= 1000000007) c[i][i] -= 1000000007;
    }
    d = zero;
    for (i = 0; i < 16; i++)
      for (j = 0; j < 16; j++)
        for (k = 0; k < 16; k++)
          d[i][j] = (d[i][j] + (long long)b[i][k] * c[k][j]) % 1000000007;
    c = calc2(x - 1);
    for (i = 0; i < 16; i++)
      for (j = 0; j < 16; j++) {
        d[i][j] += c[i][j];
        if (d[i][j] >= 1000000007) d[i][j] -= 1000000007;
      }
    return d;
  }
}
vector<vector<int> > calc(int x) {
  vector<vector<int> > all, half, ans;
  int i, j;
  if (x == 0) {
    ans = zero;
    return ans;
  }
  all = calc1(x);
  half = calc1(x / 2);
  ans = all;
  for (i = 0; i < 16; i++)
    for (j = 0; j < 16; j++) {
      ans[i][j] += half[i][j];
      if (ans[i][j] >= 1000000007) ans[i][j] -= 1000000007;
    }
  return ans;
}
int main() {
  int i, j, k, ans, l, r, tmp;
  vector<vector<int> > b, c;
  scanf("%d%d", &l, &r);
  zero.clear();
  for (i = 0; i < 16; i++) {
    vector<int> a1;
    a1.clear();
    for (j = 0; j < 16; j++) a1.push_back(0);
    zero.push_back(a1);
  }
  a = zero;
  for (i = 0; i < 4; i++)
    for (j = 0; j < 4; j++) {
      if (i == j) continue;
      if ((i == 2) && (j == 3)) continue;
      if ((i == 3) && (j == 2)) continue;
      if ((i == 0) && (j == 1)) continue;
      if ((i == 1) && (j == 0)) continue;
      for (k = 0; k < 4; k++) {
        if (j == k) continue;
        if ((i == 0) && (j == 2) && (k == 1)) continue;
        if ((i == 1) && (j == 2) && (k == 0)) continue;
        if ((j == 2) && (k == 3)) continue;
        if ((j == 3) && (k == 2)) continue;
        if ((j == 0) && (k == 1)) continue;
        if ((j == 1) && (k == 0)) continue;
        a[i * 4 + j][j * 4 + k] = 1;
      }
    }
  if (l == 1) {
    tmp = 4;
    l = 2;
  } else {
    tmp = 0;
  }
  ans = 0;
  b = calc(r - 1);
  c = calc(l - 2);
  for (i = 0; i < 16; i++)
    for (j = 0; j < 16; j++) {
      b[i][j] -= c[i][j];
      if (b[i][j] < 0) b[i][j] += 1000000007;
    }
  for (i = 0; i < 4; i++)
    for (j = 0; j < 4; j++) {
      if (i == j) continue;
      if ((i == 2) && (j == 3)) continue;
      if ((i == 3) && (j == 2)) continue;
      if ((i == 0) && (j == 1)) continue;
      if ((i == 1) && (j == 0)) continue;
      for (k = 0; k < 16; k++) {
        ans += b[i * 4 + j][k];
        if (ans >= 1000000007) ans -= 1000000007;
      }
    }
  if (ans % 2 == 0)
    ans /= 2;
  else
    ans = (ans + 1000000007) / 2;
  ans += tmp;
  if (ans >= 1000000007) ans -= 1000000007;
  printf("%d\n", ans);
  return 0;
}
