#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFLL = 1e18;
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 5;
long long mds[3];
int n, l, r;
long long dp[MAXN][3];
long long solve(int n, int m) {
  if (n == 0) return m == 0;
  if (dp[n][m] != -1) return dp[n][m];
  return dp[n][m] =
             (mds[0] * solve(n - 1, m) + mds[1] * solve(n - 1, (m + 1) % 3) +
              mds[2] * solve(n - 1, (m + 2) % 3)) %
             MOD;
}
int main() {
  scanf("%d", &n);
  scanf("%d %d", &l, &r);
  r++;
  memset(dp, -1, sizeof(dp));
  for (int i = 0; i < 3; i++) mds[i] = (r - l) / 3;
  for (int i = 0; i < (r - l) % 3; i++) mds[(l + i) % 3]++;
  printf("%lld\n", solve(n, 0));
  return 0;
}
