#include <bits/stdc++.h>
using namespace std;
const int p = 1e9 + 7;
const int N = 2e5 + 5;
long long n, f[N][3];
int main() {
  ios::sync_with_stdio(false);
  long long l, r;
  cin >> n >> l >> r;
  long long a, b, c;
  a = r / 3 - (l - 1) / 3;
  b = (r + 2) / 3 - (l + 1) / 3;
  c = (r + 1) / 3 - l / 3;
  f[0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    f[i][0] = ((f[i - 1][0] * a) % p + (f[i - 1][1] * c) % p +
               (f[i - 1][2] * b) % p) %
              p;
    f[i][1] = ((f[i - 1][0] * b) % p + (f[i - 1][1] * a) % p +
               (f[i - 1][2] * c) % p) %
              p;
    f[i][2] = ((f[i - 1][0] * c) % p + (f[i - 1][1] * b) % p +
               (f[i - 1][2] * a) % p) %
              p;
  }
  cout << f[n][0] << endl;
  return 0;
}
