#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
const int N = 200005;
const int mod = 1e9 + 7;
int n, l, r;
int m[4];
ll dp[N][4];
ll f(int id, int sum) {
  if (id == n) return sum == 0;
  ll &ans = dp[id][sum];
  if (ans != -1) return ans;
  ans = (f(id + 1, sum) * m[0]) % mod;
  ans += (f(id + 1, (sum + 1) % 3) * m[1]) % mod;
  ans += (f(id + 1, (sum + 2) % 3) * m[2]) % mod;
  ans %= mod;
  return ans;
}
int main() {
  scanf("%d %d %d", &n, &l, &r);
  m[0] = r / 3 - (l - 1) / 3;
  m[1] = (r + 2) / 3 - (l + 1) / 3;
  m[2] = (r + 1) / 3 - l / 3;
  memset(dp, -1, sizeof dp);
  printf("%lld\n", f(0, 0));
  return 0;
}
