{-# LANGUAGE BangPatterns #-}
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as C
import Data.List

r' :: IO [Int]
r' = unfoldr (C.readInt . C.dropWhile (==' ')) <$> C.getLine

-- editorial
main = do
    [n,k] <- r'
    xs <- UM.replicate (k+1) 0
    calc <- U.freeze =<< tab n k k xs
    print $ U.foldr1' (+%) $ U.imap (*%) calc

over n k x = (div k x) ^% n

tab n k 0 xs = return xs
tab n k x xs = do
    y <- foldr (+%) 0 <$> mapM (UM.read xs) [2*x,3*x..k]
    UM.write xs x (over n k x -% y)
    tab n k (x-1) xs


mdl = 1000000007

(^%) :: Int -> Int -> Int
b ^% e = powAux (b `rem` mdl) e 1 `mod` mdl
    where 
        powAux _ 0 !ac = ac
        powAux b e !ac = powAux (b*b `rem` mdl) (e `quot` 2)
            (if odd e then b*ac `rem` mdl else ac)

(+%), (-%), (*%), (/%) :: Int -> Int -> Int
a +% b = (a + b) `rem` mdl
a -% b = (a - b) `mod` mdl
a *% b = (a * b) `rem` mdl
a /% b = (a * invMod b) `mod` mdl
    where   invMod :: Int -> Int
            invMod = (^% (mdl-2))