#include <bits/stdc++.h>
const int MOD = 1000000007;
int pow(int x, int p) {
  int ret = 1 % MOD;
  while (p) {
    if (p & 1) ret = (long long)ret * x % MOD;
    x = (long long)x * x % MOD;
    p >>= 1;
  }
  return ret;
}
int sum(int x) {
  if (x == 0) return 0;
  if (x == 1) return 4;
  long long ret = 0;
  if (x % 2 == 1) {
    ret = 11LL * (pow(3, x / 2) + MOD - 1) % MOD;
  } else {
    ret = 8LL + 19LL * (pow(3, x / 2 - 1) + MOD - 1) % MOD;
  }
  return (ret + 4) % MOD;
}
const int rev = 500000004;
int LL(int x) {
  int ret = sum(x) + sum((x + 1) / 2);
  return (long long)ret * rev % MOD;
}
int main() {
  int l, r;
  int x;
  while (scanf("%d%d", &l, &r) != -1) {
    int ret = LL(r) - LL(l - 1);
    ret = (ret + MOD) % MOD;
    printf("%d\n", ret);
  }
  return 0;
}
