#include <bits/stdc++.h>
using namespace std;
long long dp[200002][3], u[3], p = 1e9 + 7;
int main() {
  long long n, l, r;
  cin >> n >> l >> r;
  r -= l - 1;
  u[0] = u[1] = u[2] = r / 3;
  if (r % 3) u[l % 3]++;
  if (r % 3 == 2) u[(l + 1) % 3]++;
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        dp[i][(j + k) % 3] =
            (dp[i][(j + k) % 3] + (dp[i - 1][k] * u[j]) % p) % p;
      }
    }
  }
  cout << dp[n][0];
}
