#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
long long a[maxn], n, l, r;
long long dp[maxn][3];
int main() {
  scanf("%lld %lld %lld", &n, &l, &r);
  long long a = r / 3 - (l - 1) / 3;
  long long b = (r + 2) / 3 - (l + 2 - 1) / 3;
  long long c = (r + 1) / 3 - (l + 1 - 1) / 3;
  dp[1][0] = a;
  dp[1][1] = b;
  dp[1][2] = c;
  for (int i = 2; i <= n; i++) {
    dp[i][0] = (dp[i - 1][0] * a % mod + dp[i - 1][1] * c % mod +
                dp[i - 1][2] * b % mod) %
               mod;
    dp[i][1] = (dp[i - 1][0] * b % mod + dp[i - 1][1] * a % mod +
                dp[i - 1][2] * c % mod) %
               mod;
    dp[i][2] = (dp[i - 1][0] * c % mod + dp[i - 1][1] * b % mod +
                dp[i - 1][2] * a % mod) %
               mod;
  }
  printf("%lld", dp[n][0]);
}
