#include <bits/stdc++.h>
using namespace std;
long long dp[200001][3];
int main() {
  long long n, l, r, a[3];
  cin >> n >> l >> r;
  int k0, k1;
  k0 = k1 = 0;
  for (int k = 0; k < 3; k++) {
    int i = l, j = r;
    while ((i + 3) % 3 != k) i++;
    while ((j + 3) % 3 != k) j--;
    a[k] = (j - i) / 3 + 1;
  }
  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] += (dp[i - 1][(j + k) % 3] * a[k]);
        dp[i][j] %= 1000000007;
      }
    }
  }
  cout << dp[n][0] << endl;
  return 0;
}
