#include <bits/stdc++.h>
using namespace std;
struct Edge {
 public:
  Edge(int source, int dest, int weight) : u(source), v(dest), w(weight){};
  int u, v, w;
};
struct option {
  bool operator()(const Edge& dp, const Edge& b) { return dp.w < b.w; }
};
template <class T>
void printArr2D(vector<vector<T>> a) {
  for (int i = 0; i < a.size(); ++i) {
    for (int j = 0; j < a[i].size(); ++j) {
      cout << a[i][j] << ' ';
    }
    cout << endl;
  }
}
template <class T>
void printArr(vector<T> a) {
  for (int i = 0; i < a.size(); ++i) {
    cout << a[i] << ' ';
  }
  cout << endl;
}
int main() {
  cin.tie(NULL), cout.tie(NULL), ios_base::sync_with_stdio(false);
  int n, l, r;
  cin >> n >> l >> r;
  vector<vector<int>> dp(n, vector<int>(3, 0));
  vector<int> k(3);
  for (int i = 0; i < 3; ++i) {
    int upper = int(floor(1.0 * (r - i) / 3));
    int lower = int(ceil(1.0 * (l - i) / 3));
    k[i] = upper - lower + 1;
  }
  for (int j = 0; j < 3; ++j) {
    dp[0][j] = k[j];
  }
  for (int i = 1; i < n; ++i) {
    for (int j = 0; j < 3; ++j) {
      dp[i][j] = (1LL * dp[i - 1][j] * k[0] % int(1e9 + 7) +
                  1LL * dp[i - 1][(3 + j - 1) % 3] * k[1] % int(1e9 + 7) +
                  1LL * dp[i - 1][(3 + j - 2) % 3] * k[2] % int(1e9 + 7)) %
                 int(1e9 + 7);
    }
  }
  cout << dp[n - 1][0];
  return 0;
}
