#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int maxm = 1e7 + 5;
const int mod = 998244353;
const int inf = 1e9 + 7;
const double PI = acos(-1.0);
const long long mo = 1e9 + 7;
const long long N = 1e6 + 10;
long long dp[maxn][3];
long long sum0, sum1, sum2;
int main() {
  long long i, n, l, r;
  scanf("%lld%lld%lld", &n, &l, &r);
  l--;
  sum0 = r / 3 - l / 3;
  sum1 = (r + 2) / 3 - (l + 2) / 3;
  sum2 = (r + 1) / 3 - (l + 1) / 3;
  dp[1][0] = sum0, dp[1][1] = sum1, dp[1][2] = sum2;
  for (i = 2; i <= n; i++) {
    dp[i][0] = ((dp[i - 1][0] * sum0) % mo + (dp[i - 1][1] * sum2) % mo +
                (dp[i - 1][2] * sum1) % mo) %
               mo;
    dp[i][1] = ((dp[i - 1][0] * sum1) % mo + (dp[i - 1][1] * sum0) % mo +
                (dp[i - 1][2] * sum2) % mo) %
               mo;
    dp[i][2] = ((dp[i - 1][0] * sum2) % mo + (dp[i - 1][1] * sum1) % mo +
                (dp[i - 1][2] * sum0) % mo) %
               mo;
  }
  printf("%lld\n", dp[n][0]);
}
