5971: ABC212 —— G - Power Pair
[Creator : ]
Description
Given is a prime number $P$.
How many pairs of integers $(x,\ y)$ satisfy the following conditions?
How many pairs of integers $(x,\ y)$ satisfy the following conditions?
- $0≤x≤P−1$
- $0≤y≤P−1$
- There exists a positive integer $n$ such that $x^n≡y\ (mod\ P)$.
Input
Input is given from Standard Input in the following format:
$P$
$P$
Output
Print the answer modulo $998244353$.
Constraints
$2≤P≤10^{12}$
$P$ is a prime number.
$P$ is a prime number.
Sample 1 Input
3
Sample 1 Output
4
Four pairs $(x,\ y)=(0,\ 0),\ (1,\ 1),\ (2,\ 1),\ (2,\ 2)$ satisfy the conditions.
Sample 2 Input
11
Sample 2 Output
64
Sample 3 Input
998244353
Sample 3 Output
329133417
HINT
题目来源:AtCoder ABC212 G题。