#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int mod = 1e9 + 7;
long long dp[maxn][3];
int num[3];
int n, l, r;
int main() {
  scanf("%d%d%d", &n, &l, &r);
  memset(dp, 0, sizeof(dp));
  int a = (r - l + 1) / 3, b = (r - l + 1) % 3;
  int s = l % 3;
  num[s] = a + (b > 0 ? 1 : 0);
  num[(s + 1) % 3] = a + (b > 1 ? 1 : 0);
  num[(s + 2) % 3] = a;
  dp[1][0] = num[0];
  dp[1][1] = num[1];
  dp[1][2] = num[2];
  for (int i = 2; i <= n; i++) {
    dp[i][0] = (dp[i - 1][0] * num[0] + dp[i - 1][1] * num[2] +
                dp[i - 1][2] * num[1]) %
               mod;
    dp[i][1] = (dp[i - 1][0] * num[1] + dp[i - 1][1] * num[0] +
                dp[i - 1][2] * num[2]) %
               mod;
    dp[i][2] = (dp[i - 1][0] * num[2] + dp[i - 1][1] * num[1] +
                dp[i - 1][2] * num[0]) %
               mod;
  }
  cout << dp[n][0] << endl;
}
