#include <bits/stdc++.h>
using namespace std;
long long n, l, r;
long long r0, r1, r2;
long long dp[200010][3];
long long mod = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  cin >> n >> l >> r;
  r0 = r / 3 - (l - 1) / 3;
  r1 = (r + 2) / 3 - (l - 1 + 2) / 3;
  r2 = (r + 1) / 3 - (l - 1 + 1) / 3;
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    dp[i][0] = ((dp[i - 1][0] * r0) % mod + (dp[i - 1][1] * r2) % mod +
                (dp[i - 1][2] * r1) % mod) %
               mod;
    dp[i][1] = ((dp[i - 1][0] * r1) % mod + (dp[i - 1][1] * r0) % mod +
                (dp[i - 1][2] * r2) % mod) %
               mod;
    dp[i][2] = ((dp[i - 1][0] * r2) % mod + (dp[i - 1][1] * r1) % mod +
                (dp[i - 1][2] * r0) % mod) %
               mod;
  }
  cout << dp[n][0] << endl;
  ;
  return 0;
}
