#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long dp[200005][5], cnt[5];
int main() {
  int n, l, r;
  cin >> n >> l >> r;
  while (l % 3 != 0 and l <= r) {
    cnt[l % 3]++;
    ++l;
  }
  while (r % 3 != 2 and l <= r) {
    cnt[r % 3]++;
    --r;
  }
  for (int i = 0; i < 3; i++) {
    cnt[i] += (r - l + 1) / 3;
    dp[1][i] = cnt[i];
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        dp[i][(j + k) % 3] += (dp[i - 1][j] * cnt[k]) % mod;
        dp[i][(j + k) % 3] %= mod;
      }
    }
  }
  cout << dp[n][0] << endl;
  return 0;
}
