#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, l, r;
  cin >> n >> l >> r;
  r++;
  long long d_0 = (r + ((3 - (r % 3)) % 3) - l) / 3;
  r++, l++;
  long long d_2 = (r + ((3 - (r % 3)) % 3) - l) / 3;
  r++, l++;
  long long d_1 = (r + ((3 - (r % 3)) % 3) - l) / 3;
  vector<vector<long long>> dp(n, vector<long long>(3, 0));
  dp[0][0] = d_0;
  dp[0][1] = d_1;
  dp[0][2] = d_2;
  for (long long i = 1; i < n; ++i) {
    dp[i][0] =
        (dp[i - 1][0] * d_0 % 1000000007 + dp[i - 1][1] * d_2 % 1000000007 +
         dp[i - 1][2] * d_1 % 1000000007) %
        1000000007;
    dp[i][1] =
        (dp[i - 1][0] * d_1 % 1000000007 + dp[i - 1][1] * d_0 % 1000000007 +
         dp[i - 1][2] * d_2 % 1000000007) %
        1000000007;
    dp[i][2] =
        (dp[i - 1][0] * d_2 % 1000000007 + dp[i - 1][1] * d_1 % 1000000007 +
         dp[i - 1][2] * d_0 % 1000000007) %
        1000000007;
  }
  cout << dp[n - 1][0];
  return 0;
}
