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