#include using namespace std; using ll = long long; using ull = unsigned long long; constexpr int MOD = 1e9 + 7; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, l, r) for (int i = (l); i < (int)(r); i++) #define all(v) v.begin(), v.end() struct Aho_lc { int X; bool init; static constexpr int sigma = 10; vector> to; vector cnt, link; Aho_lc() : cnt(1), to(1), init(0) { rep(i, sigma) to[0][i] = -1; } void add(const string &s) { int v = 0; for (char i : s) { i -= '0'; if (to[v][i] == -1) { to[v][i] = (int)to.size(); to.push_back(array()); cnt.push_back(0); rep(j, sigma) to.back()[j] = -1; } v = to[v][i]; } cnt[v]++; } void build() { assert(!init); init = 1; link.assign(to.size(), -1); queue bfs; bfs.push(0); while (bfs.size()) { int v = bfs.front(); bfs.pop(); rep(i, sigma) { int u = to[v][i]; if (u == -1) continue; link[u] = _link_search(link[v], i); cnt[u] += cnt[link[u]]; bfs.push(u); } } } int _link_search(int v, int c) { while (v != -1) { if (to[v][c] != -1) return to[v][c]; v = link[v]; } return 0; } }; void ch(ll &a, ll b) { a = (a + b) % MOD; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll N, L, R; cin >> N >> L >> R; vector ng; ll r1 = 1, r2 = 1; while (r2 <= R) { if (r2 >= L) ng.push_back(to_string(r2)); r2 += r1; r1 = r2 - r1; } Aho_lc aho; for (auto i : ng) aho.add(i); aho.build(); int M = aho.cnt.size(); vector dp(M, 0ll); dp[0] = 1; rep(i, N) { vector ndp(M, 0ll); rep(j, M) { rep(k, 10) { int v = j, u = 0; while (v != -1) { if (aho.to[v][k] != -1) { u = aho.to[v][k]; break; } v = aho.link[v]; } if (!aho.cnt[u]) ch(ndp[u], dp[j]); } } rep(j, M) { dp[j] = ndp[j]; } } ll ans = 0; rep(i, M) { ch(ans, dp[i]); } ch(ans, MOD - 1); cout << ans << '\n'; }