#c221001. 求幂和

求幂和

Power Sum

Problem Description

You are given three numbers nn, mm, pp. You need to compute ∑i=1min  mod  p\sum\limits_{i=1}^{m} i^n \space \bmod \space p.

Input Format

Three positive integers nn, mm, pp. It is guaranteed that pp is prime and p>n+1p > n + 1.

Output Format

One positive integer representing the result.

Sample Input

2 3 101

Sample Output

14

Hint

For 100%100\% of the data, 1≤n≤20001\leq n\leq 2000, 1≤m,p≤1091\leq m, p \leq 10^9.