#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const LL base = 1e9 + 7;
const int N = 2e5 + 5;
LL cache[3][N];
LL x[3];
int n;
LL dp(int k, int r) {
  if (k == n) {
    return r == 0;
  }
  if (cache[r][k] != -1) return cache[r][k];
  LL rv = 0;
  rv += x[0] * dp(k + 1, r) % base;
  rv %= base;
  rv += x[1] * dp(k + 1, (r + 1) % 3) % base;
  rv %= base;
  rv += x[2] * dp(k + 1, (r + 2) % 3) % base;
  rv %= base;
  return cache[r][k] = rv;
}
int main() {
  int l, r;
  cin >> n >> l >> r;
  l += 3;
  r += 3;
  x[0] = r / 3 - (l - 1) / 3;
  x[1] = (r - 1) / 3 - (l - 2) / 3;
  x[2] = (r - 2) / 3 - (l - 3) / 3;
  memset(cache, -1, sizeof cache);
  LL res = dp(0, 0);
  cout << res << endl;
}
