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)

let rec power ( * ) e m n =
  if n <= 0 then e
  else power ( * ) (if n land 1 = 0 then e else m * e) (m * m) (n lsr 1)

let m = 1000000007
let ( +^ ) x y = (x + y) mod m
let ( -^ ) x y = x +^ (m - y)
let ( *^ ) x y = (x * y) mod m
let ( /^ ) x y = power ( *^ ) x y (m - 2)

let () = Scanf.scanf "%d %s" @@ fun k s ->
  (* comb.(i) = (|S| - 1 + i)C(|S| - 1) *)
  let comb = Array.make (k + 1) 0 in
  comb.(0) <- 1;
  for i = 1 to k do
    comb.(i) <- (String.length s - 1 + i) *^ comb.(i - 1) /^ i
  done;
  Printf.printf "%d\n" @@
  Array.fold_left ( +^ ) (power ( *^ ) 1 26 k) @@
  Array.init k @@ fun i ->
    power ( *^ ) (power ( *^ ) comb.(k - i) 25 (k - i)) 26 i