#Lutece2204. min25!

min25!

Migrated from Lutece 2204 min25!

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

i=1ni3+i2+i+1[i为质数]\sum_{i=1}^{n}{i^3 + i^2 + i + 1}[i为质数]

由于答案非常大,你只需要输出答案模pp就行了。

Input

一个nn,一个pp,我们保证pp为素数。

Output

题目要求的和在模pp意义下的答案

Samples

2 17
15

Constraints

1n1e101\leq n \leq 1e10

2p1e9+72 \leq p \leq 1e9 + 7

Resources

Forsaken的min_25筛入门题