#include <bits/stdc++.h>
using namespace std;
int n, l, r;
int dp[200010][3];
const int MOD = 1e9 + 7;
int main() {
  cin >> n >> l >> r;
  memset(dp, 0, sizeof dp);
  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++) {
        int ll = (k - l) % 3;
        if (ll < 0) ll += 3;
        ll += l;
        int rr = (r - k) % 3;
        if (rr < 0) rr += 3;
        rr = r - rr;
        long long cur =
            (long long)((rr - ll) / 3 + 1) * dp[i - 1][(j - k + 3) % 3];
        dp[i][j] += cur % MOD;
        dp[i][j] %= MOD;
      }
    }
  }
  cout << dp[n][0];
}
