// #define _GLIBCXX_DEBUG // for STL debug (optional) #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long int; using int64 = long long int; template void chmax(T &a, T b) {a = max(a, b);} template void chmin(T &a, T b) {a = min(a, b);} template void chadd(T &a, T b) {a = a + b;} int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; const int INF = 1LL << 29; const ll LONGINF = 1LL << 60; const ll MOD = 1000000007LL; void test() { vector fib(2, 1); for(int i=2; ; i++) { ll nxt_fib = fib[i-1] + fib[i-2]; if(nxt_fib > (ll)1e18) break; else { fprintf(stderr, "fib[%d] = %lld\n", i, nxt_fib); fib.emplace_back(nxt_fib); } } } // ModInt begin using ll = long long; template struct ModInt { ll v; ll mod_pow(ll x, ll n) const { return (!n) ? 1 : (mod_pow((x*x)%mod,n/2) * ((n&1)?x:1)) % mod; } ModInt(ll a = 0) : v((a %= mod) < 0 ? a + mod : a) {} ModInt operator+ ( const ModInt& b ) const { return (v + b.v >= mod ? ModInt(v + b.v - mod) : ModInt(v + b.v)); } ModInt operator- () const { return ModInt(-v); } ModInt operator- ( const ModInt& b ) const { return (v - b.v < 0 ? ModInt(v - b.v + mod) : ModInt(v - b.v)); } ModInt operator* ( const ModInt& b ) const {return (v * b.v) % mod;} ModInt operator/ ( const ModInt& b ) const {return (v * mod_pow(b.v, mod-2)) % mod;} bool operator== ( const ModInt &b ) const {return v == b.v;} bool operator!= ( const ModInt &b ) const {return !(*this == b); } ModInt& operator+= ( const ModInt &b ) { v += b.v; if(v >= mod) v -= mod; return *this; } ModInt& operator-= ( const ModInt &b ) { v -= b.v; if(v < 0) v += mod; return *this; } ModInt& operator*= ( const ModInt &b ) { (v *= b.v) %= mod; return *this; } ModInt& operator/= ( const ModInt &b ) { (v *= mod_pow(b.v, mod-2)) %= mod; return *this; } ModInt pow(ll x) { return ModInt(mod_pow(v, x)); } // operator int() const { return int(v); } // operator long long int() const { return v; } }; template ModInt pow(ModInt n, ll k) { return ModInt(n.mod_pow(n.v, k)); } template ostream& operator<< (ostream& out, ModInt a) {return out << a.v;} template istream& operator>> (istream& in, ModInt& a) { in >> a.v; return in; } // ModInt end using mint = ModInt; int nxt_state[750][10]; mint dp[5010][750]; int main() { // test(); ll N, L, R; cin >> N >> L >> R; vector pfx; auto add_str = [&](string pat) { if(stoll(pat) < L) return; if(R < stoll(pat)) return; for(int i=0; i<=(int)pat.size(); i++) { pfx.emplace_back(pat.substr(0, i)); } }; add_str("1"); vector fib(2, 1); for(int i=2; ; i++) { ll nxt_fib = fib[i-1] + fib[i-2]; if(nxt_fib > (ll)1e18) break; else { add_str(to_string(nxt_fib)); fib.emplace_back(nxt_fib); } } sort(pfx.begin(), pfx.end()); pfx.erase(unique(pfx.begin(), pfx.end()), pfx.end()); int M = pfx.size(); vector ng_state(M, false); for(int i=0; i