#include <bits/stdc++.h>
int dr[] = {2, 2, -2, -2, 1, -1, 1, -1};
int dc[] = {1, -1, 1, -1, 2, 2, -2, -2};
int dr1[] = {0, 0, 0, 1, 1, 1, -1, -1, -1};
int dc1[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1};
int dr2[] = {0, 0, 1, -1};
int dc2[] = {1, -1, 0, 0};
using namespace std;
long long int dp[200005][3];
long long int p, p1, p2, n;
long long int three(long long int ind, long long int s) {
  if (ind > n) {
    return (s == 0);
  }
  if (dp[ind][s] != -1) return dp[ind][s];
  long long int r = (three(ind + 1, s) * p) % 1000000007;
  long long int r1 = (three(ind + 1, (s + 1) % 3) * p1) % 1000000007;
  long long int r2 = (three(ind + 1, (s + 2) % 3) * p2) % 1000000007;
  dp[ind][s] = (r + r1 + r2) % 1000000007;
  return dp[ind][s];
}
int main() {
  long long int l, r, i;
  while (cin >> n >> l >> r) {
    p = p1 = p2 = 0;
    p = (r) / 3 - (l - 1) / 3;
    long long int one = -1, one1 = -1;
    for (i = l; i <= r; i++) {
      if (i % 3 == 1) {
        one = i;
        break;
      }
    }
    for (i = r; i >= l; i--) {
      if (i % 3 == 1) {
        one1 = i;
        break;
      }
    }
    if (one != -1) {
      p1 = (one1 - one + 1) / 3 + 1;
    }
    p2 = r - l + 1 - p - p1;
    memset(dp, -1, sizeof(dp));
    long long int ans = three(1, 0);
    cout << ans << endl;
  }
  return 0;
}
