#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
using namespace std;
const long long maxn = 2e5 + 9;
long long dp[maxn][3];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  memset(dp, 0, sizeof(dp));
  long long n, l, r;
  cin >> n >> l >> r;
  long long diff = r - l + 1;
  vector<long long> nos(3, diff / 3);
  if (diff % 3 != 0) {
    nos[l % 3]++;
    if (diff % 3 == 2) {
      nos[(l + 1) % 3]++;
    }
  }
  dp[1][0] = nos[0];
  dp[1][1] = nos[1];
  dp[1][2] = nos[2];
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j < 3; j++) {
      dp[i][j] = (((dp[i - 1][0] * (nos[(j + 3) % 3] % mod)) % mod) +
                  ((dp[i - 1][1] * (nos[(j + 2) % 3] % mod)) % mod) +
                  ((dp[i - 1][2] * (nos[(j + 1) % 3] % mod)) % mod)) %
                 mod;
    }
  }
  cout << dp[n][0] << "\n";
  return 0;
}
