Problem:
Score: 600 points

Problem Statement

How many strings can be obtained by applying the following operation on a string S exactly K times: "choose one lowercase English letter and insert it somewhere"?

The answer can be enormous, so print it modulo (10^9+7).

Constraints

K is an integer between 1 and 10^6 (inclusive).

S is a string of length between 1 and 10^6 (inclusive) consisting of lowercase English letters.

Input

Input is given from Standard Input in the following format:

K
S

Output

Print the number of strings satisfying the condition, modulo (10^9+7).

Sample Input 1

5
oof

Sample Output 1

575111451

For example, we can obtain proofend, moonwolf, and onionpuf, while we cannot obtain oofsix, oofelevennn, voxafolt, or fooooooo.

Sample Input 2

37564
whydidyoudesertme

Sample Output 2

318008117

Solution in Haskell (GHC 8.8.3) (judge verdict: Time Limit Exceeded)

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE ScopedTypeVariables #-}

import Data.Char
import Control.Monad

import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM

import qualified Data.ByteString.Char8 as BS
import Data.Maybe

import Data.Bits

import GHC.TypeLits
import Data.Int
import Data.Proxy

getInts = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine


{-- Mod Int --}
data Mint (m :: Nat) = Mint {getMintValue :: Integer} deriving (Eq, Show)
 
getMintMod :: forall p. KnownNat p => Mint p -> Integer
getMintMod = natVal

makeMint :: forall p. KnownNat p => Integer -> Mint p
makeMint a = let r = Mint $ fromInteger $ a `mod` (getMintMod r) in r

instance KnownNat p => Num (Mint p) where
  (Mint a) + (Mint b) = makeMint $ a + b
  (Mint a) - (Mint b) = makeMint $ a - b
  (Mint a) * (Mint b) = makeMint $ a * b
  negate (Mint a) = makeMint $ negate a
  abs = id
  signum (Mint a) = if a == 0 then 0 else 1
  fromInteger = makeMint

invMint :: forall p. KnownNat p => Mint p -> Mint p
invMint m = let p = getMintMod m in m ^ (p - 2)

powerMint :: forall p. KnownNat p => Integer -> Integer -> Mint p
powerMint n p
  | p >= 0 = (fromInteger n :: Mint p) ^ p
  | otherwise = invMint $ powerMint n (-p)


type M = Mint 1000000007



data FactorialTable m =
  FactorialTable {fac :: V.Vector m, ifac :: V.Vector m} deriving Show

getFactorialTable :: forall p. KnownNat p => Int -> FactorialTable (Mint p)
getFactorialTable n = FactorialTable {fac = fac, ifac = ifac}
  where
    fac = V.scanl (*) 1 $ V.generate n (\i -> fromIntegral (i + 1))
    ifac =
      let x = invMint (fac V.! n)
      in V.reverse $ V.unfoldrN (n + 1) (\(b, k) -> let a = b * (fromIntegral k) in Just (b, (a, k - 1))) (x, n)


fP :: forall p. KnownNat p => FactorialTable (Mint p) -> Int -> Int -> Mint p
fP FactorialTable {fac = fac, ifac = ifac} n k
  | n < k || n < 0 || k < 0 = 0
  | otherwise = (fac V.! n) * (ifac V.! (n-k))

fC :: forall p. KnownNat p => FactorialTable (Mint p) -> Int -> Int -> Mint p
fC f@FactorialTable {fac = fac, ifac = ifac} n k
  | n < k || n < 0 || k < 0 = 0
  | otherwise = fP f n k * (ifac V.! k)

fH :: forall p. KnownNat p => FactorialTable (Mint p) -> Int -> Int -> Mint p
fH f n k
  | n == 0 && k == 0 = 1
  | otherwise = fC f (n + k - 1) k




main :: IO ()
main = do
  k <- readLn :: IO Int
  s <- BS.getLine

  let n = BS.length s

  let f = getFactorialTable 3000000 :: FactorialTable M
  
  print $ getMintValue $ sum $ map
    (\i ->
        (powerMint 25 (fromIntegral i) :: M) *
        (powerMint 26 (fromIntegral (k-i)) :: M) *
        fH f n i
    ) [0..k]