#include using namespace std; using LL = long long; using ULL = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) static const int char_cnt = 62; int char_to_idx(char c) { if ('0' <= c && c <= '9') return c - '0'; if ('a' <= c && c <= 'z') return c - 'a' + 10; if ('A' <= c && c <= 'Z') return c - 'A' + 36; return -1; } struct AhoCorasick { struct Node { int to[char_cnt]; int z = 0; int hit = -1; int suf = -1; Node() { rep(i, char_cnt) to[i] = -1; } }; int N; vector V; struct SuffixRelation { int from, to; }; vector Suf; AhoCorasick(vector T) { V.push_back(Node()); N = T.size(); rep(i, N) { int p = 0; for (char c : T[i]) { int d = char_to_idx(c); if (V[p].to[d] == -1) { V[p].to[d] = V.size(); V.push_back(Node()); } p = V[p].to[d]; } if (V[p].hit != -1) Suf.push_back({ V[p].hit, i }); else V[p].hit = i; } T.clear(); queue Q; rep(t, char_cnt) { if (V[0].to[t] == -1) V[0].to[t] = 0; else { V[V[0].to[t]].z = 0; Q.push(V[0].to[t]); } } while (Q.size()) { int q = Q.front(); Q.pop(); rep(t, char_cnt) { if (V[q].to[t] != -1) { Q.push(V[q].to[t]); int p = V[q].z; while (V[p].to[t] == -1) { p = V[p].z; } V[V[q].to[t]].z = V[p].to[t]; } else { int p = V[q].z; while (V[p].to[t] == -1) { p = V[p].z; } V[q].to[t] = V[p].to[t]; } } V[q].suf = V[V[q].z].suf; if (V[q].hit != -1) { if (V[q].suf != -1) Suf.push_back({ V[q].hit, V[q].suf }); V[q].suf = V[q].hit; } } reverse(Suf.begin(), Suf.end()); } }; int main() { const ULL M = 1000000007; ULL F[88]; vector S; F[0] = F[1] = 1; for (int i = 2; i < 88; i++) F[i] = F[i - 1] + F[i - 2]; ULL N, L, R; cin >> N >> L >> R; rep(i, 88) if (L <= F[i] && F[i] <= R) S.push_back(to_string(F[i])); auto V = move(AhoCorasick(S).V); vector dp(V.size()); dp[0] = 1; rep(n, N) { vector buf(V.size()); rep(i, V.size()) rep(t, 10) { int p = i; buf[V[p].to[t]] += dp[i]; } rep(i, V.size()) { dp[i] = buf[i] % M; if (V[i].suf != -1) dp[i] = 0; } } ULL ans = 0; for (ULL a : dp) ans += a; ans += (M - 1); ans %= M; cout << ans << endl; return 0; }