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