#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long l, r, n, res1 = 0, res2 = 0, res3 = 0, r1 = 0, r2 = 0, r3 = 0;
  long long mod = 1000000007;
  cin >> n >> l >> r;
  long long ind1 = 0;
  long long ind2 = 0;
  for (long long i = l; i <= r; i++) {
    if (i % 3 == 0) {
      ind1 = i;
      break;
    }
  }
  for (long long i = r; i >= l; i--) {
    if (i % 3 == 0) {
      ind2 = i;
      break;
    }
  }
  if (ind1 != 0 && ind2 != 0) {
    res3 = (ind2 - ind1) / 3 + 1;
  }
  ind1 = 0;
  ind2 = 0;
  for (long long i = l; i <= r; i++) {
    if (i % 3 == 1) {
      ind1 = i;
      break;
    }
  }
  for (long long i = r; i >= l; i--) {
    if (i % 3 == 1) {
      ind2 = i;
      break;
    }
  }
  if (ind1 != 0 && ind2 != 0) {
    res1 = (ind2 - ind1) / 3 + 1;
  }
  ind1 = 0;
  ind2 = 0;
  for (long long i = l; i <= r; i++) {
    if (i % 3 == 2) {
      ind1 = i;
      break;
    }
  }
  for (long long i = r; i >= l; i--) {
    if (i % 3 == 2) {
      ind2 = i;
      break;
    }
  }
  if (ind1 != 0 && ind2 != 0) {
    res2 = (ind2 - ind1) / 3 + 1;
  }
  r1 = res1;
  r2 = res2;
  r3 = res3;
  for (long long i = 2; i <= n; i++) {
    long long res11 = res1;
    long long res22 = res2;
    long long res33 = res3;
    res3 = (r1 * res22 + r2 * res11 + res33 * r3) % mod;
    res2 = (r1 * res11 + res22 * r3 + res33 * r2) % mod;
    res1 = (res11 * r3 + res22 * r2 + res33 * r1) % mod;
  }
  cout << res3 % mod;
}
