#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long n, l, r;
long long a[3];
long long ans[200010][3];
void cal(int x, int d) {
  if (l == 0) return;
  for (int i = 0; i < 3; i++) {
    a[i] += (x / 3 + (x % 3 >= i)) * d;
  }
}
int main() {
  cin >> n >> l >> r;
  cal(r, 1);
  cal(l - 1, -1);
  ans[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        ans[i][(j + k) % 3] += ans[i - 1][j] * a[k];
        ans[i][(j + k) % 3] %= mod;
      }
    }
  }
  cout << ans[n][0] << endl;
  return 0;
}
