#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 200500;
const long long INF = 0x3f3f3f3f;
const long long LINF = 0x1f3f3f3f3f3f3f3f;
const long long MOD = (long long)1e9 + 7;
const long long OVER_FLOW = 0xffffffff;
long long s, T, n, m, M, k, A, B;
long long res[40];
long long dp[MAXN][4];
long long get_nm(long long x, long long delta) {
  x -= delta;
  if (x < 0)
    return 0;
  else {
    x /= 3;
    return x + 1;
  }
}
int main() {
  ios::sync_with_stdio(false);
  long long l, r;
  cin >> n >> l >> r;
  long long m_0 = get_nm(r, 0) - get_nm(l - 1, 0);
  long long m_1 = get_nm(r, 1) - get_nm(l - 1, 1);
  long long m_2 = get_nm(r, 2) - get_nm(l - 1, 2);
  dp[1][0] = m_0, dp[1][1] = m_1, dp[1][2] = m_2;
  for (long long i = 2; i <= n; i++) {
    dp[i][0] = dp[i - 1][0] * m_0 % MOD + dp[i - 1][1] * m_2 % MOD +
               dp[i - 1][2] * m_1 % MOD;
    dp[i][0] %= MOD;
    dp[i][1] = dp[i - 1][0] * m_1 % MOD + dp[i - 1][1] * m_0 % MOD +
               dp[i - 1][2] * m_2 % MOD;
    dp[i][1] %= MOD;
    dp[i][2] = dp[i - 1][0] * m_2 % MOD + dp[i - 1][1] * m_1 % MOD +
               dp[i - 1][2] * m_0 % MOD;
    dp[i][2] %= MOD;
  }
  cout << dp[n][0] << endl;
  return 0;
}
