#include using namespace std; // #include // using namespace atcoder; using ll = long long; const ll MOD = 998'244'353; //const ll MOD = 1000'000'007; const ll INF = (1LL<<30)-1; const ll LINF = (1LL<<62)-1; //#define _GLIBCXX_DEQUE_BUF_SIZE 512 // int:[-2'147'483'648 : 2'147'483'647] // ll:[-9'223'372'036'854'775'808 : 9'223'372'036'854'775'807] #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define repi(i, a, n) for (ll i = a; i < (ll)(n); i++) #define pb(a) push_back(a) #define PS(a) cout<<(a)<<" "; #define PL(a) cout<<(a)<; using Pll = pair; template using V = vector; templateostream &operator<<(ostream &os, const vector< T > &v) {for(int i = 0; i < (int) v.size(); i++) {os << v[i] << (i + 1 != (int) v.size() ? " " : "");}return os;} templateistream &operator>>(istream &is, vector< T > &v) {for(T &in : v) is >> in;return is;} template ostream &operator<<(ostream &os, const pair &p) {os << p.first << ' ' << p.second; return os;} template istream &operator>>(istream &is, pair &p) { is >> p.first >> p.second; return is;} template ostream &operator<<(ostream &os, const array< T , sz > &v) {for(int i = 0; i < sz; i++) {os << v[i] << (i + 1 != (int) v.size() ? " " : "");}return os;} template istream &operator>>(istream &is, array< T , sz > &v) {for(T& in:v){cin>>in;} return is;} template void chmin(T& t, const U& u) {if (t > u) t = u;} template void chmax(T& t, const U& u) {if (t < u) t = u;} #if __has_include() #include using namespace atcoder; // ostream &operator<<(ostream &os, const mint x) {os<>(istream &is, mint& x){ll val; is >> val; x = val; return is;} #endif void solve() { ll L,R,M; cin>>L>>R>>M; auto f = [&](ll x)->ll { EL(x) ll res = 0; ll g = 1; ll fact = 1; for(ll i=1;i<=x;i++){ res += g*fact; res %= M; g *= fact; g %= M; fact *= i; fact %= M; ES(res) ES(g) EL(fact) if(g*fact%M==0) break; } return res; }; ll ans = f(R)-f(L); ans += M*10; ans %= M; PL(ans) return; } int main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(15); int TT = 1; //cin>>TT; for(int tt = 0; tt