#include <bits/stdc++.h>
using namespace std;
long long int dp[1100005][3];
long long int power(long long int x, long long int y) {
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return power(x, y / 2) * power(x, y / 2);
  else
    return x * power(x, y / 2) * power(x, y / 2);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int l, r, n;
  cin >> n >> l >> r;
  long long int a, b, c;
  a = r / 3 - l / 3;
  if (l % 3 == 0) a++;
  long long int p = r - l + 1 - a;
  if (p % 2 == 0)
    b = c = p / 2;
  else {
    if (l % 3 == 1)
      b = p - p / 2, c = p / 2;
    else
      c = p - p / 2, b = p / 2;
  }
  dp[0][0] = a;
  dp[0][1] = b;
  dp[0][2] = c;
  for (int i = 1; i <= n - 1; i++) {
    dp[i][0] =
        ((dp[i - 1][0] * a) % 1000000007 + (dp[i - 1][1] * c) % 1000000007 +
         (dp[i - 1][2] * b) % 1000000007) %
        1000000007;
    dp[i][1] =
        ((dp[i - 1][0] * b) % 1000000007 + (dp[i - 1][1] * a) % 1000000007 +
         (dp[i - 1][2] * c) % 1000000007) %
        1000000007;
    dp[i][2] =
        ((dp[i - 1][0] * c) % 1000000007 + (dp[i - 1][1] * b) % 1000000007 +
         (dp[i - 1][2] * a) % 1000000007) %
        1000000007;
  }
  cout << dp[n - 1][0] << endl;
  return 0;
}
