#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); long long l, r, m; cin >> l >> r >> m; if (m == 1) { cout << 0 << '\n'; return 0; } vector fac(m, 1); for (int i = 2; i < m; i++) { fac[i] = fac[i - 1] * i; fac[i] %= m; } vector pre(m, 1); for (int i = 2; i < m; i++) { pre[i] = pre[i - 1] * fac[i]; pre[i] %= m; } if (l >= m) { cout << 0 << '\n'; } else { r = min(r, m - 1); long long ans = 0; for (long long i = l; i <= r; i++) { ans += pre[i]; ans %= m; } cout << ans << '\n'; } }