#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e5 + 5;
const int mod = 1e9 + 7;
long long dp[MAX_N][3], cnt[3];
int main() {
  int n, l, r;
  cin >> n >> l >> r;
  for (int i = 0; i < 3; i++) {
    cnt[i] = 0;
    int l2 = l, r2 = r;
    while (l2 <= r && l2 % 3 != i) l2++;
    while (r2 >= l && r2 % 3 != i) r2--;
    if (r2 >= l2) cnt[i] = (r2 - l2) / 3 + 1;
  }
  memset(dp, 0, sizeof dp);
  dp[1][0] = cnt[0], dp[1][1] = cnt[1], dp[1][2] = cnt[2];
  for (int i = 2; i <= n; i++) {
    dp[i][0] =
        (((dp[i - 1][0] * cnt[0]) % mod + (dp[i - 1][1] * cnt[2]) % mod) % mod +
         (dp[i - 1][2] * cnt[1]) % mod) %
        mod;
    dp[i][1] =
        (((dp[i - 1][0] * cnt[1]) % mod + (dp[i - 1][1] * cnt[0]) % mod) % mod +
         (dp[i - 1][2] * cnt[2]) % mod) %
        mod;
    dp[i][2] =
        (((dp[i - 1][0] * cnt[2]) % mod + (dp[i - 1][1] * cnt[1]) % mod) % mod +
         (dp[i - 1][2] * cnt[0]) % mod) %
        mod;
  }
  cout << dp[n][0] << endl;
  return 0;
}
