#include "bits/stdc++.h" // #include // using namespace __gnu_cxx; using namespace std; // #include // using namespace __gnu_pbds; // template using Tree = tree, rb_tree_tag, tree_order_statistics_node_update>; template istream& operator >> (istream& in, vector& v) { for (auto &it:v) in >> it; return in; } template ostream& operator << (ostream& os, const vector& v) { for (auto it:v) os << it << " "; return os; } template istream& operator >> (istream& in, pair& p) { in >> p.first >> p.second; return in; } template ostream& operator << (ostream& os, const pair& p) { os << p.first << " " << p.second; return os; } template void minn(T1& a, T2 b) { a = min(a,b); } template void maxx(T1& a, T2 b) { a = max(a,b); } #define int long long // #define double long double #define pb push_back #define all(v) v.begin(),v.end() #define allr(v) v.rbegin(),v.rend() #define sz(v) (int)v.size() #define deb(x) cerr<<#x<<"="<>l>>r>>m; minn(r,m); vector f(r+1); f[0]=1; int ans=0; for(int i=1;i<=r;i++){ f[i]=(f[i-1]*i)%m; } for(int i=1;i<=r;i++){ f[i]=(f[i-1]*f[i])%m; if(i>=l)ans=(ans+f[i])%m; } cout<sync_with_stdio(0); int tc=1; // cin>>tc; while(tc--){ solve(); } return 0; }