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