#include <bits/stdc++.h>
using namespace std;
const int maxn = 200020;
int n, l, r;
long long f[maxn][3];
int main() {
  cin >> n >> l >> r;
  f[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 3; j++) {
      long long num = (r + j) / 3 - (l - 1 + j) / 3;
      for (int k = 0; k < 3; k++) {
        f[i][(k + j) % 3] =
            (f[i][(k + j) % 3] + f[i - 1][k] * num) % 1000000007LL;
      }
    }
  }
  cout << f[n][0] << endl;
  return 0;
}
