#include <bits/stdc++.h>
using namespace std;
const int dx[8] = {0, -1, 0, 1, -1, -1, 1, 1},
          dy[8] = {1, 0, -1, 0, -1, 1, -1, 1};
long long dp[200005][4];
int main() {
  long long n, l, r;
  scanf("%lld%lld%lld", &n, &l, &r);
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 3; j++) {
      long long num = (r - j + 3) / 3 - (l + 2 - j) / 3;
      for (int k = 0; k < 3; k++) {
        dp[i][(j + k) % 3] =
            (dp[i][(j + k) % 3] + dp[i - 1][k] * num) % 1000000007;
      }
    }
  }
  printf("%lld", dp[n][0]);
  return 0;
}
