#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int mod = 1000000007;
  long long int n, l, r;
  cin >> n >> l >> r;
  long long int m[3];
  long long int range = r - l + 1;
  m[0] = range / 3;
  m[1] = range / 3;
  m[2] = range / 3;
  if (range % 3 == 1) m[l % 3]++;
  if (range % 3 == 2) {
    m[l % 3]++;
    m[(l + 1) % 3]++;
  }
  long long int dp[n + 1][3];
  dp[1][0] = m[0] % mod;
  dp[1][1] = m[1] % mod;
  dp[1][2] = m[2] % mod;
  for (int i = 2; i <= n; i++) {
    dp[i][0] = (dp[i - 1][0] * m[0]) % mod;
    dp[i][0] += (dp[i - 1][1] * m[2]) % mod;
    dp[i][0] += (dp[i - 1][2] * m[1]) % mod;
    dp[i][0] %= mod;
    dp[i][1] = (dp[i - 1][0] * m[1]) % mod;
    dp[i][1] += (dp[i - 1][2] * m[2]) % mod;
    dp[i][1] += (dp[i - 1][1] * m[0]) % mod;
    dp[i][1] %= mod;
    dp[i][2] = (dp[i - 1][0] * m[2]) % mod;
    dp[i][2] += (dp[i - 1][1] * m[1]) % mod;
    dp[i][2] += (dp[i - 1][2] * m[0]) % mod;
    dp[i][2] %= mod;
  }
  cout << dp[n][0] % mod;
}
