#include <bits/stdc++.h>
const int N = 2e5 + 50;
const int mod = 1e9 + 7;
int n, l, r, a[3];
int f[N][3];
int main() {
  scanf("%d%d%d", &n, &l, &r);
  f[0][0] = 1;
  a[0] = r / 3 - (l - 1) / 3;
  a[1] = (r + 2) / 3 - (l + 1) / 3;
  a[2] = (r + 1) / 3 - (l) / 3;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 3; k++)
        f[i][j] =
            (f[i][j] + 1ll * f[i - 1][k] * a[(2 * k + j) % 3] % mod) % mod;
  printf("%d\n", f[n][0]);
}
