This page is still under construction.

Parts of this page are still being built. What you see may change.

Overflowing Uncertainty

Time limit1sMemory limit256 MB

Summary
For each interval [i,j] compute the probability that the gcd of j-i+1 independent uniform values in [1,Y] is coprime with Y, sum over all intervals, and report the numerator modulo 1e9+9 with denominator Y^N.
Level

Hard9 of 10

Topics
Number theory, Dynamic programming, Combinatorics, Math
Solved
No attempts yet

Problem

To torment the contest participants, Wookje made a strange sequence of length N. Curiously, its elements exist only probabilistically until we look at them, each one sitting in a superposition of several positive integers. Pinning down an element requires a special process called observation.

For a positive integer Y ≥ 2 and a closed interval [ℓ, r], observation and the result of an observation are defined as follows.

Let the ℓ-th through r-th elements of the sequence be random variables Aℓ, Aℓ+1, ..., Ar. At the moment some Ai is observed, Ai is fixed to an arbitrary positive integer in the closed interval [1, Y], becoming Bi. (Every positive integer is fixed with the same probability 1/Y.) Each element is observed independently, and this yields Bℓ, Bℓ+1, ..., Br from Aℓ, Aℓ+1, ..., Ar. The result of an observation is the greatest common divisor of Bℓ, Bℓ+1, ..., Br. Observed elements immediately return to their original state and exist only probabilistically again, with no effect on later observations.

Using this sequence, Wookje defined the following strange function.

fY(i,j)={0if i>jthe probability that the result of observing [i, j] is coprime with Yotherwisef_Y(i, j) = \begin{cases} 0 & \text{if } i > j \\ \text{the probability that the result of observing [i, j] is coprime with } Y & \text{otherwise} \end{cases}

Find the integer Z satisfying the following.

∑i=1N∑j=1NfY(i,j)=ZYN\sum_{i=1}^{N}{\sum_{j=1}^{N}{f_Y (i, j)}} = {Z\over Y^N}

Z can be extremely large, so compute its remainder modulo 10^9 + 9 and print it.

Input

The first line gives the length of the sequence N and the positive integer Y. (1 ≤ N ≤ 10^5, 2 ≤ Y ≤ 10^9)

Output

Print the remainder of the integer Z modulo 10^9 + 9.

Examples2

  1. Example 1

    Input
    1 3
    
    Expected output
    2
    
  2. Example 2

    Input
    3 12
    
    Expected output
    5488