#include // #include using namespace std; // using namespace atcoder; #define DEBUG(x) cerr<<#x<<": "< #define vl vector #define vii vector< vector > #define vll vector< vector > #define vs vector #define pii pair #define pis pair #define psi pair #define pll pair template pair operator+(const pair &s, const pair &t) { return pair(s.first + t.first, s.second + t.second); } template pair operator-(const pair &s, const pair &t) { return pair(s.first - t.first, s.second - t.second); } template ostream& operator<<(ostream& os, pair p) { os << "(" << p.first << ", " << p.second << ")"; return os; } #define X first #define Y second #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep1(i,n) for(int i=1;i<=(int)(n);i++) #define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--) #define rrep1(i,n) for(int i=(int)(n);i>0;i--) #define REP(i,a,b) for(int i=a;i bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; } #define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end()); const ll inf = 1000000001; const ll INF = (ll)1e18 + 1; const long double pi = 3.1415926535897932384626433832795028841971L; #define Sp(p) cout<> n >> l >> r; vl f(2); f[0] = f[1] = 1; for (int i = 2; f.back() <= r; i++) { ll x = f[i - 1] + f[i - 2]; f.push_back(x); } vector fib; rep1 (i, f.size() - 1) { if (in(f[i], l, r + 1)) { fib.push_back(to_string(f[i])); } } // DEBUG_VEC(fib); // return 0; map, ll> dp, dp2; dp[vector(0)] = 1; ll ans = 0; rep (_, n) { dp2.clear(); // DEBUG(dp.size()); // for (auto itr = dp.begin(); itr != dp.end(); itr++) { // DEBUG_VEC(itr->first); // DEBUG(itr->second); // } for (auto itr = dp.begin(); itr != dp.end(); itr++) { vector now = itr->first; ll x = itr->second; rep (i, 10) { vector nex; bool flag = true; rep (j, now.size()) { int idx = now[j].first, k = now[j].second; if (fib[idx][k] == '0' + i) { if (k == fib[idx].size() - 1) { flag = false; break; } nex.push_back(pii(idx, k + 1)); } } if (not flag) continue; rep (j, fib.size()) { if (fib[j][0] == '0' + i) { if (fib[j].size() == 1) { flag = false; break; } nex.push_back(pii(j, 1)); } } if (not flag) continue; (dp2[nex] += x) %= MOD; } } swap(dp, dp2); } for (auto itr = dp.begin(); itr != dp.end(); itr++) { (ans += itr->second) %= MOD; } cout << (ans - 1 + MOD) % MOD << endl; }