#include <bits/stdc++.h>
using namespace std;
long long n, l, r, res[2][3], cnt[3], nw, nx, a;
int main() {
  scanf("%d %d %d", &n, &l, &r);
  a = r - l + 1;
  cnt[2] = cnt[1] = cnt[0] = a / 3;
  if (a % 3 == 1) {
    ++cnt[l % 3];
  } else if (a % 3 == 2) {
    ++cnt[l % 3];
    ++cnt[(l + 1) % 3];
  }
  res[0][0] = cnt[1];
  res[0][1] = cnt[2];
  res[0][2] = cnt[0];
  nw = 0;
  nx = 1;
  for (int i = 1; i < n; ++i) {
    res[nx][0] =
        (res[nw][0] * cnt[0] + res[nw][1] * cnt[2] + res[nw][2] * cnt[1]) %
        1000000007;
    res[nx][1] =
        (res[nw][0] * cnt[1] + res[nw][1] * cnt[0] + res[nw][2] * cnt[2]) %
        1000000007;
    res[nx][2] =
        (res[nw][0] * cnt[2] + res[nw][1] * cnt[1] + res[nw][2] * cnt[0]) %
        1000000007;
    swap(nx, nw);
  }
  printf("%d", res[nw][2]);
  return 0;
}
