#include <bits/stdc++.h>
using namespace std;
const long long maxn = 5e5 + 20, maxt = 200, Mod = 1e9 + 7;
long long n, l, r, a[3], ans, dp[maxn][3];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> l >> r;
  if (l == r && l % 3 != 0 && n % 3 != 0) {
    return cout << 0, 0;
  }
  if (l == r - 1 && l % 3 == 1 && n == 1) {
    return cout << 0, 0;
  }
  while (r % 3 > 0 && r > l) {
    a[r % 3]++;
    r--;
  }
  if (r != l) {
    r--;
    a[0]++;
  }
  while (l % 3 > 0 && r > l) {
    a[l % 3]++;
    l++;
  }
  if (r != l) {
    a[0] += (r - l + 1) / 3;
    a[1] += (r - l + 1) / 3;
    a[2] += (r - l + 1) / 3;
  } else
    a[r % 3]++;
  dp[1][0] = a[0];
  dp[1][1] = a[1];
  dp[1][2] = a[2];
  for (long long i = 2; i <= n; i++) {
    dp[i][0] =
        (dp[i - 1][0] * a[0] + dp[i - 1][1] * a[2] + dp[i - 1][2] * a[1]) % Mod;
    dp[i][1] =
        (dp[i - 1][0] * a[1] + dp[i - 1][1] * a[0] + dp[i - 1][2] * a[2]) % Mod;
    dp[i][2] =
        (dp[i - 1][0] * a[2] + dp[i - 1][1] * a[1] + dp[i - 1][2] * a[0]) % Mod;
  }
  cout << dp[n][0];
  return 0;
}
