#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, p = 1e9 + 7;
long long n, l, r, s[N][3], a[3];
int main() {
  scanf("%lld%lld%lld", &n, &l, &r);
  a[0] = (r) / 3 - (l - 1) / 3;
  a[1] = (r + 2) / 3 - (l + 1) / 3;
  a[2] = (r + 1) / 3 - (l) / 3;
  s[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    s[i][0] =
        (s[i - 1][0] * a[0] + s[i - 1][1] * a[2] + s[i - 1][2] * a[1]) % p;
    s[i][1] =
        (s[i - 1][0] * a[1] + s[i - 1][1] * a[0] + s[i - 1][2] * a[2]) % p;
    s[i][2] =
        (s[i - 1][0] * a[2] + s[i - 1][1] * a[1] + s[i - 1][2] * a[0]) % p;
  }
  printf("%lld", s[n][0]);
}
