#include <bits/stdc++.h>
using namespace std;
const int64_t mod = 1e9 + 7;
const int64_t M = 2e5 + 5;
int64_t n, l, r, dp[M][3];
int64_t rem0, rem1, rem2;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> l >> r;
  rem0 = r / 3 - (l - 1) / 3;
  rem1 = (r + 1) / 3 - l / 3;
  rem2 = (r + 2) / 3 - (l + 1) / 3;
  dp[1][0] = rem0, dp[1][1] = rem1, dp[1][2] = rem2;
  for (int64_t i = 2; i <= n; i++) {
    dp[i][0] =
        (rem0 * dp[i - 1][0] + rem1 * dp[i - 1][2] + rem2 * dp[i - 1][1]) % mod;
    dp[i][1] =
        (rem0 * dp[i - 1][1] + rem1 * dp[i - 1][0] + rem2 * dp[i - 1][2]) % mod;
    dp[i][2] =
        (rem0 * dp[i - 1][2] + rem1 * dp[i - 1][1] + rem2 * dp[i - 1][0]) % mod;
  }
  cout << dp[n][0];
  return 0;
}
