Problem:
Score : 500 points

Problem Statement

Consider sequences \{A_1,...,A_N\} of length N consisting of integers between 1 and K (inclusive).

There are K^N such sequences. Find the sum of \gcd(A_1, ..., A_N) over all of them.

Since this sum can be enormous, print the value modulo (10^9+7).

Here \gcd(A_1, ..., A_N) denotes the greatest common divisor of A_1, ..., A_N.

Constraints

2 \leq N \leq 10^5

1 \leq K \leq 10^5

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N K

Output

Print the sum of \gcd(A_1, ..., A_N) over all K^N sequences, modulo (10^9+7).

Sample Input 1

3 2

Sample Output 1

9

\gcd(1,1,1)+\gcd(1,1,2)+\gcd(1,2,1)+\gcd(1,2,2)
+\gcd(2,1,1)+\gcd(2,1,2)+\gcd(2,2,1)+\gcd(2,2,2)
=1+1+1+1+1+1+1+2=9

Thus, the answer is 9.

Sample Input 2

3 200

Sample Output 2

10813692

Sample Input 3

100000 100000

Sample Output 3

742202979

Be sure to print the sum modulo (10^9+7).

Solution in Haskell (GHC 8.8.3) (judge verdict: Accepted)

-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import Data.Char (isSpace)
import Data.Int (Int64)
import Data.List (unfoldr)
import Control.Monad
import qualified Data.Vector.Unboxing as U
import qualified Data.Vector.Unboxing.Mutable as UM
import qualified Data.ByteString.Char8 as BS

main = do
  [n,k] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let v :: U.Vector IntMod
      v = U.create $ do
        v <- UM.replicate (k+1) 0
        forM_ [1..k] $ \i -> do
          UM.write v i $! fromIntegral (k `quot` i) ^ n
        return v
      w :: U.Vector IntMod
      w = U.create $ do
        w <- U.thaw v
        forM_ [k,k-1..1] $ \i -> do
          s <- sum <$> sequence [ UM.read w j | j <- [2*i,3*i..k] ]
          UM.modify w (subtract s) i
        return w
  print $ sum [ fromIntegral i * w U.! i | i <- [1..k] ]

modulus :: Int64
modulus = 10^9 + 7

newtype IntMod = IntMod { getIntMod :: Int64 } deriving Eq

instance Show IntMod where
  show (IntMod x) = show x

instance Num IntMod where
  IntMod x + IntMod y = IntMod ((x + y) `rem` modulus)
  IntMod x - IntMod y = IntMod ((x - y) `mod` modulus)
  IntMod x * IntMod y = IntMod ((x * y) `rem` modulus)
  negate (IntMod x) = IntMod (negate x `mod` modulus)
  fromInteger x = IntMod (fromInteger (x `mod` fromIntegral modulus))
  abs = undefined; signum = undefined

{-# RULES
"fromIntegral/Int64->IntMod" forall (x :: Int64).
  fromIntegral x = IntMod (x `mod` modulus)
"fromIntegral/Int->IntMod" forall (x :: Int).
  fromIntegral x = IntMod (fromIntegral x `mod` modulus)
  #-}

instance U.Unboxable IntMod where
  type Rep IntMod = Int64