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 OCaml (4.10.0) (judge verdict: Accepted)

Scanf.scanf "%d %s" (fun k s ->
    let n = String.length s in
    let z = 1_000_000_007 in
    let extgcd x y =
        let rec eg r0 r1 a0 a1 b0 b1 =
            if r1 = 0 then a0 else
                let q1 = r0 / r1 in
                eg r1 (r0 mod r1) a1 (a0 - q1 * a1) b1 (b0 - q1 * b1)
        in
        eg x y 1 0 0 1
    in
    let inv x y = (* 1/x in mod y *)
        let c = extgcd x y in
        if c < 0 then c + y else c
    in
    let ( +@) a b = (a + b) mod z in
    let ( *@) a b = (a * b) mod z in
    let ( /@) a b = a *@ inv b z in
    let rec loop i pre acc =
        if i > k then acc else loop (i + 1) (pre *@ (25 * (n + i)) /@ (1 + i)) (acc *@ 26 +@ pre)
    in
    loop 0 1 0 |> Printf.printf "%d\n"
)