#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using uint = unsigned int; using ll = long long; using ull = unsigned long long; constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); } template using V = vector; template using VV = V>; template T pow(T x, ll n, T r = 1) { while (n) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; } template struct ModInt { uint v; ModInt() : v{0} {} ModInt(ll v) : v{normS(v%MD+MD)} {} explicit operator bool() const {return v != 0;} static uint normS(const uint &x) {return (x; const int MN = TEN(5) + TEN(3); Mint fact[MN], iFac[MN]; Mint kaku[MN]; void first() { fact[0] = Mint(1); for (int i = 1; i < MN; i++) { fact[i] = fact[i-1] * i; } for (int i = 0; i < MN; i++) { iFac[i] = Mint(1)/fact[i]; } kaku[0] = Mint(1); kaku[1] = Mint(0); for (int i = 2; i < MN; i++) { kaku[i] = Mint(i-1) * (kaku[i-2] + kaku[i-1]); } } Mint C(int n, int k) { if (n < k || n < 0) return Mint(0); return fact[n] * iFac[k] * iFac[n-k]; } int main() { first(); int n; ll l, r; cin >> n >> l >> r; Mint ans = 0; if (l == 0) { ans += fact[n] - fact[n-1]; } for (int i = 1; i <= 61; i++) { ll u = 1LL << i; if (l <= u && u <= r) { // cout << "OK " << i << endl; ans += C(n-1, i-1) * kaku[n-i]; } } cout << ans.v << endl; return 0; }