#include <bits/stdc++.h>
using namespace std;
long long n, l, r, yu[3], f[2][3];
int main() {
  scanf("%lld%lld%lld", &n, &l, &r);
  yu[0] = r / 3 - ((l - 1) / 3), yu[1] = (r + 2) / 3 - ((l + 1) / 3),
  yu[2] = (r + 1) / 3 - (l / 3);
  f[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    memset(f[i & 1], 0, sizeof(f[i & 1]));
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 3; k++)
        f[i & 1][(j + k) % 3] =
            (f[i & 1][(j + k) % 3] + f[(i - 1) & 1][j] * yu[k]) % 1000000007;
  }
  printf("%lld\n", f[n & 1][0]);
  return 0;
}
