#include <bits/stdc++.h>
using namespace std;
long long dp[200005][3];
int main() {
  long long n, l, r;
  scanf("%lld%lld%lld", &n, &l, &r);
  if (l == r) {
    long long kk = l % 1000000007;
    ;
    if ((kk * n) % 3 != 0)
      printf("0");
    else
      printf("1");
    return 0;
  }
  long long l1, r1;
  l1 = l;
  r1 = r;
  long long count0 = 0, count1 = 0, count2 = 0;
  while (l1 % 3 != 0) l1++;
  while (r1 % 3 != 0) r1--;
  count0 = (r1 - l1) / 3 + 1;
  l1 = l;
  r1 = r;
  while (l1 % 3 != 1) l1++;
  while (r1 % 3 != 1) r1--;
  count1 = (r1 - l1) / 3 + 1;
  l1 = l;
  r1 = r;
  while (l1 % 3 != 2) l1++;
  while (r1 % 3 != 2) r1--;
  count2 = (r1 - l1) / 3 + 1;
  dp[1][0] = count0;
  dp[1][1] = count1;
  dp[1][2] = count2;
  for (long long i = 2; i <= n; ++i) {
    dp[i][0] += dp[i - 1][0] * count0;
    dp[i][0] %= 1000000007;
    ;
    dp[i][0] += dp[i - 1][1] * count2;
    dp[i][0] %= 1000000007;
    ;
    dp[i][0] += dp[i - 1][2] * count1;
    dp[i][0] %= 1000000007;
    ;
    dp[i][1] += dp[i - 1][0] * count1;
    dp[i][1] %= 1000000007;
    ;
    dp[i][1] += dp[i - 1][1] * count0;
    dp[i][1] %= 1000000007;
    ;
    dp[i][1] += dp[i - 1][2] * count2;
    dp[i][1] %= 1000000007;
    ;
    dp[i][2] += dp[i - 1][0] * count2;
    dp[i][2] %= 1000000007;
    ;
    dp[i][2] += dp[i - 1][1] * count1;
    dp[i][2] %= 1000000007;
    ;
    dp[i][2] += dp[i - 1][2] * count0;
    dp[i][2] %= 1000000007;
    ;
  }
  printf("%lld", dp[n][0]);
  return 0;
}
