#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
const int N = 2e5 + 10;
const int M = 1e9 + 7;
int n, l, r, a[3];
long long int dp[N][3];
long long int solve(int i, int m) {
  if (i == n) return !m;
  long long int &re = dp[i][m];
  if (re != -1) return re;
  long long int ans = 0;
  ans = (a[0] % M * solve(i + 1, m) % M) % M;
  ans = (ans % M + (a[1] % M * solve(i + 1, (m + 1) % 3)) % M) % M;
  ans = (ans % M + (a[2] % M * solve(i + 1, (m + 2) % 3)) % M) % M;
  return re = ans;
}
int main() {
  cin >> 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;
  memset(dp, -1, sizeof(dp));
  cout << solve(0, 0) << endl;
  return 0;
}
