#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch - '0' < 0 || ch - '0' > 9) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch - '0' >= 0 && ch - '0' <= 9) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long n, l, r;
long long f[200010][3];
long long a[3];
void add(long long &x, long long y) { x = (x + y) % 1000000007; }
void get() {
  a[0] = r / 3 - (l - 1) / 3;
  a[1] = (r + 1) / 3 - (l) / 3;
  a[2] = (r + 2) / 3 - (l + 1) / 3;
}
int main() {
  n = read();
  l = read();
  r = read();
  get();
  f[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++)
        add(f[i + 1][(j + k) % 3], f[i][j] * a[k] % 1000000007);
    }
  }
  cout << f[n][0] << endl;
  return 0;
}
