#include <bits/stdc++.h>
using namespace std;
const long long N = 300100, mod = 1e9 + 7, mod2 = 1e9 + 9, mod3 = 998244353,
                sq = 450, base = 727, lg = 30;
long long n, m, x, y, z, w, k, l, r, ans, t, a[3], dp[3][N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> l >> r;
  a[0] = (r / 3) - ((l + 2) / 3 - 1);
  l++;
  r++;
  a[2] = (r / 3) - ((l + 2) / 3 - 1);
  l++;
  r++;
  a[1] = (r / 3) - ((l + 2) / 3 - 1);
  dp[0][0] = a[0];
  dp[1][0] = a[1];
  dp[2][0] = a[2];
  for (int i = 1; i < n; i++) {
    dp[0][i] = ((dp[0][i - 1] * a[0]) % mod + (dp[2][i - 1] * a[1]) % mod +
                (dp[1][i - 1] * a[2]) % mod) %
               mod;
    dp[1][i] = ((dp[1][i - 1] * a[0]) % mod + (dp[0][i - 1] * a[1]) % mod +
                (dp[2][i - 1] * a[2]) % mod) %
               mod;
    dp[2][i] = ((dp[2][i - 1] * a[0]) % mod + (dp[1][i - 1] * a[1]) % mod +
                (dp[0][i - 1] * a[2]) % mod) %
               mod;
  }
  cout << dp[0][n - 1];
  return 0;
}
