#include <bits/stdc++.h>
using namespace std;
void input(int n, int a[]) {
  for (int i = 0; i < n; ++i) cin >> a[i];
}
long long bin_expo(long long A, long long B, long long M) {
  long long res = 1LL;
  while (B > 0) {
    if (B % 2 == 1) {
      res = (res * A) % M;
    }
    A = (A * A) % M;
    B = B / 2;
  }
  return res;
}
int main() {
  long long n, l, r;
  cin >> n >> l >> r;
  long long a[n + 5][4];
  memset(a, 0, sizeof(a));
  a[0][0] = (r - l + 1) / 3;
  a[0][1] = (r - l + 1) / 3;
  a[0][2] = (r - l + 1) / 3;
  if ((r - l + 1) % 3 == 2) {
    a[0][l % 3]++;
    a[0][(l + 1) % 3]++;
  }
  if ((r - l + 1) % 3 == 1) a[0][l % 3]++;
  for (int i = 1; i < n; i++) {
    a[i][0] = ((a[i - 1][0] * a[0][0]) % 1000000007 +
               (a[i - 1][1] * a[0][2]) % 1000000007 +
               (a[i - 1][2] * a[0][1]) % 1000000007) %
              1000000007;
    a[i][1] = (a[i - 1][2] * a[0][2]) % 1000000007 +
              (a[i - 1][0] * a[0][1]) % 1000000007 +
              (a[i - 1][1] * a[0][0]) % 1000000007;
    a[i][1] %= 1000000007;
    a[i][2] = (a[i - 1][1] * a[0][1]) % 1000000007 +
              (a[i - 1][0] * a[0][2]) % 1000000007 +
              (a[i - 1][2] * a[0][0]) % 1000000007;
    a[i][2] %= 1000000007;
  }
  cout << a[n - 1][0] << endl;
  return 0;
}
