#include #include #include #include #include #include #include #include #include #include using ll = long long; using namespace std; int main() { ll n, l, m, lim = 0, pro = 1, cumpro = 1, sum1 = 0; cin >> n >> l >> m; for (ll i = 1; i <= m; i++){ pro *= i; if(!(pro%m)){ lim = i; break; } pro %= m; } pro = 1; for (ll i = 1; i < lim; i++){ pro *= i; cumpro *= pro; if (!(cumpro%m)) break; cumpro %= m; if (i >= n) sum1 += cumpro%m; sum1 %= m; } cout << sum1 << endl; }