atcoder#ABC212G. [ABC212G] Power Pair

[ABC212G] Power Pair

Score : 600600 points

Problem Statement

Given is a prime number PP.

How many pairs of integers (x,y)(x, y) satisfy the following conditions?

  • 0xP10 \leq x \leq P-1
  • 0yP10 \leq y \leq P-1
  • There exists a positive integer nn such that xny(modP)x^n \equiv y \pmod{P}.

Since the answer may be enormous, print it modulo 998244353998244353.

Constraints

  • 2P10122 \leq P \leq 10^{12}
  • PP is a prime number.

Input

Input is given from Standard Input in the following format:

PP

Output

Print the answer modulo 998244353998244353.

3
4

Four pairs (x,y)=(0,0),(1,1),(2,1),(2,2)(x, y) = (0, 0), (1, 1), (2, 1), (2, 2) satisfy the conditions.

11
64
998244353
329133417