#include <bits/stdc++.h>
using namespace std;
long long ways[3], n;
long long dp[200001][3];
long long dfs(long long st, long long state) {
  if (dp[st][state] != -1) return dp[st][state];
  if (st == n) {
    if (state == 0)
      return 1;
    else
      return 0;
  }
  return dp[st][state] = (ways[0] * dfs(st + 1, state) +
                          ways[1] * dfs(st + 1, (state + 1) % 3) +
                          ways[2] * dfs(st + 1, (state + 2) % 3)) %
                         1000000007;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  for (long long i = 0; i < 200001; i++)
    for (long long j = 0; j < 3; j++) dp[i][j] = -1;
  long long l, r;
  cin >> n >> l >> r;
  ways[0] = r / 3 - (l - 1) / 3;
  ways[1] = (r + 2) / 3 - (l + 1) / 3;
  ways[2] = (r + 1) / 3 - l / 3;
  cout << dfs(0, 0) << endl;
  return 0;
}
