#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++) #define chmin(x, y) (x) = min((x), (y)) #define chmax(x, y) (x) = max((x), (y)) #define all(x) (x).begin(),(x).end() #define inf 1e18 #define mod 1000000007 using namespace std; typedef long long llint; typedef pair P; struct AhoCorasick{ struct TrieNode{ int num, sum; int next[26], suff; TrieNode(){ num = sum = 0; for(int i = 0; i < 26; i++) next[i] = -1; } }; vector trie; AhoCorasick(){ init(); } void init(){ trie.clear(); trie.push_back(TrieNode()); } int seek(string &s) { int p = 0; for(int i = 0; i < s.size(); i++){ int c = s[i]-'0'; if(trie[p].next[c] == -1){ trie.push_back(TrieNode()); trie[p].next[c] = (int)trie.size()-1; } p = trie[p].next[c]; } return p; } int trans(int v, int c) { if(trie[v].next[c] != -1) return trie[v].next[c]; if(v == 0) return 0; return trans(trie[v].suff, c); } void addString(string &s, int x = 1) { int p = seek(s); trie[p].num += x; } void makeSuffixLink() { queue Q; Q.push(0); trie[0].suff = 0; int v; while(Q.size()){ v = Q.front(); Q.pop(); trie[v].sum = trie[v].num + trie[trie[v].suff].sum; for(int i = 0; i < 26; i++){ int u = trie[v].next[i]; if(u == -1) continue; trie[u].suff = trans(trie[v].suff, i); if(v == 0) trie[u].suff = 0; Q.push(u); } } } }; llint n; llint l, r; vector vec; vector svec; map mp; AhoCorasick aho; llint dp[5005][5005]; string get(llint x) { string ret; for(;x;x/=10) ret += x%10 + '0'; reverse(all(ret)); return ret; } int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> l >> r; llint a = 0, b = 1; while(1){ llint c = a+b; if(c > 1e18) break; if(c >= l && c <= r) vec.push_back(c); a = b, b = c; } for(int i = 0; i < vec.size(); i++){ string s = get(vec[i]); aho.addString(s); } aho.makeSuffixLink(); llint m = aho.trie.size(); dp[0][0] = 1; for(int i = 0; i < n; i++){ for(int j = 0; j < m; j++){ for(int k = 0; k < 10; k++){ int nj = aho.trans(j, k); if(aho.trie[nj].sum == 0) (dp[i+1][nj] += dp[i][j]) %= mod; } } } llint ans = mod-1; for(int i = 0; i < m; i++) ans += dp[n][i], ans %= mod; cout << ans << endl; return 0; }