#ABC300E. [ABC300E] Dice Product 3

[ABC300E] Dice Product 3

Score : 500500 points

Problem Statement

You have an integer 11 and a die that shows integers between 11 and 66 (inclusive) with equal probability. You repeat the following operation while your integer is strictly less than NN:

  • Cast a die. If it shows xx, multiply your integer by xx.

Find the probability, modulo 998244353998244353, that your integer ends up being NN.

How to find a probability modulo $998244353$? We can prove that the sought probability is always rational. Additionally, under the constraints of this problem, when that value is represented as \frac{P}{Q} with two coprime integers P and Q, we can prove that there is a unique integer R such that R \times Q \equiv P\pmod{998244353} and 0 \leq R \lt 998244353. Find this R.

Constraints

  • 2N10182 \leq N \leq 10^{18}
  • NN is an integer.

Input

The input is given from Standard Input in the following format:

NN

Output

Print the probability, modulo 998244353998244353, that your integer ends up being NN.

6
239578645

One of the possible procedures is as follows.

  • Initially, your integer is 11.
  • You cast a die, and it shows 22. Your integer becomes 1×2=21 \times 2 = 2.
  • You cast a die, and it shows 44. Your integer becomes 2×4=82 \times 4 = 8.
  • Now your integer is not less than 66, so you terminate the procedure.

Your integer ends up being 88, which is not equal to N=6N = 6.

The probability that your integer ends up being 66 is 725\frac{7}{25}. Since 239578645×257(mod998244353)239578645 \times 25 \equiv 7 \pmod{998244353}, print 239578645239578645.

7
0

No matter what the die shows, your integer never ends up being 77.

300
183676961
979552051200000000
812376310