#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, r, l;
  cin >> n >> r >> l;
  long long dp[n][3];
  double rd = (double)r;
  double ld = (double)l;
  dp[0][0] = floor(ld / (3.0)) - ceil(rd / (3.0)) + 1;
  dp[0][1] = floor((ld - 1.0) / (3.0)) - ceil((rd - 1.0) / (3.0)) + 1;
  dp[0][2] = floor((ld - 2) / (3.0)) - ceil((rd - 2) / (3.0)) + 1;
  for (long long i = 1; i < n; ++i) {
    dp[i][0] = ((dp[0][0] * dp[i - 1][0]) % 1000000007 +
                (dp[i - 1][1] * dp[0][2]) % 1000000007 +
                (dp[i - 1][2] * dp[0][1]) % 1000000007) %
               1000000007;
    dp[i][1] = ((dp[i - 1][2] * dp[0][2]) % 1000000007 +
                (dp[i - 1][0] * dp[0][1]) % 1000000007 +
                (dp[i - 1][1] * dp[0][0]) % 1000000007) %
               1000000007;
    dp[i][2] = ((dp[i - 1][1] * dp[0][1]) % 1000000007 +
                (dp[i - 1][0] * dp[0][2]) % 1000000007 +
                (dp[i - 1][2] * dp[0][0]) % 1000000007) %
               1000000007;
  }
  cout << dp[n - 1][0] << endl;
  return 0;
}
