#include #include #include #include #include #include #include using namespace std; #define int long long constexpr int MOD = 1000000007; struct trie{ int NUM_a; char A; trie** child; trie *fail; int val; int c; int d; trie() { NUM_a = 10; A = '0'; val = 0; child = new trie*[NUM_a]; for(int _ = 0; _ < NUM_a; _++) child[_] = NULL; c = 0; d = -1; fail = NULL; } ~trie() { all_del(); delete[] child; } void add(char *c){ this->val++; if(*c == '\0') return; if(this->child[*c-A] == NULL){ trie *node = new trie(); this->child[*c-A] = node; } // else this->child[*c-A]->val++; this->child[*c-A]->add(c+1); } int find(char *c){ if(*c == '\0'){ int con = 0; for(int _ = 0; _ < NUM_a; _++){ if(this->child[_] != NULL) con += this->child[_]->val; } return this->val - con; } if(this->child[*c-A] == NULL) return 0; else return this->child[*c-A]->find(c+1); } void del(char *c){ this->val--; if(*c == '\0') return ; if(this->child[*c-A] != NULL){ this->child[*c-A]->del(c+1); if(child[*c-A]->val == 1) { delete child[*c-A]; child[*c-A] = NULL; } } } void all_del(){ for(int _ = 0; _ < NUM_a; _++){ if(this->child[_] != NULL) { child[_]->all_del(); delete child[_]; child[_] = NULL; } } } void print(int depth = 0){ for(int _ = 0; _ < NUM_a; _++){ if(child[_] != NULL){ for(int __ = 0; __ < depth; __++) cout<<" "; cout<<(char)(A+_)<<" "<val<<" "; cout<fail<<" "<d; cout<child[_]->print(depth+1); } } } }; struct Aho_Corasick { trie tr; vector d; vector S; void init(vector &X){ S = X; d.clear(); queue Q; for(string s : S){ tr.add(&s[0]); } tr.d = d.size(); d.push_back(&tr); for(int _ = 0; _ < tr.NUM_a; _++){ if(tr.child[_] == NULL) continue; tr.child[_]->fail = &tr; Q.push(tr.child[_]); } while(!Q.empty()){ trie *t = Q.front(); Q.pop(); int con = 0; t->d = d.size(); d.push_back(t); for(int _ = 0; _ < tr.NUM_a; _++){ if(t->child[_] == NULL) continue; con += t->child[_]->val; trie *u = t->fail; while(u != &tr && u->child[_] == NULL) u = u->fail; if(u->child[_] == NULL) t->child[_]->fail = u; else t->child[_]->fail = u->child[_]; Q.push(t->child[_]); } t->c = t->fail->c + t->val - con; } // tr.print(); } int match(string &s){ int res = 0; trie *t = &tr; for(char c : s){ int C = c-t->A; while(true){ if(t->child[C] != NULL){ t = t->child[C]; break; } else if(t == &tr) { break; } else { t = t->fail; } } res += t->c; } return res; } int match(string &s, vector &con){ int N = d.size(); con = vector(N); int res = 0; trie *t = &tr; for(char c : s){ int C = c-t->A; while(true){ if(t->child[C] != NULL){ t = t->child[C]; break; } else if(t == &tr) { break; } else { t = t->fail; } } res += t->c; con[t->d] += t->c; } return res; } int solve(int N){ vector dp(d.size()); dp[0] = 1; for(int i = 0; i < N; i++){ vector> ndp(d.size(), vector(tr.NUM_a)); vector ndp2(d.size()); for(int j = (int)d.size()-1; j >= 0; j--){ for(int _ = 0; _ < tr.NUM_a; _++){ if(d[j]->child[_] != NULL) { ndp[d[j]->child[_]->d][_] += dp[j] + ndp[j][_]; ndp[j][_] = 0; ndp[d[j]->child[_]->d][_] %= MOD; } else if(d[j]->fail != NULL){ ndp[d[j]->fail->d][_] += dp[j] + ndp[j][_]; ndp[j][_] = 0; ndp[d[j]->fail->d][_] %= MOD; } else { ndp[j][_] += dp[j]; ndp[j][_] %= MOD; } } } for(int j = (int)d.size()-1; j >= 0; j--){ int con = 0, sum = 0; for(int _ = 0; _ < tr.NUM_a; _++){ sum += ndp[j][_]; sum %= MOD; if(d[j]->child[_] != NULL) { con += d[j]->child[_]->val; } } if(!d[j]->c) { ndp2[j] = sum; } } swap(dp, ndp2); } int res = 0; for(int i = 0; i < d.size(); i++){ res += dp[i]; res %= MOD; } res = (res + MOD - 1) % MOD; return res; } }; signed main(){ Aho_Corasick ac; vector S; int N, L, R; vector f; cin>>N>>L>>R; f.push_back(1); f.push_back(1); for(;f.back() <= R;){ f.push_back(f[f.size()-1] + f[f.size()-2]); } for(int i = 0; i < f.size(); i++){ if(L <= f[i] && f[i] <= R) { S.push_back(to_string(f[i])); } } ac.init(S); cout<