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 Lua (Lua 5.3.5) (judge verdict: Accepted)

local mod = 1000000007
local mfl = math.floor

local function bmul(x, y)
  return (x * y) % mod
end

local function badd(x, y)
  return (x + y) % mod
end

local fact = {1}
local invs = {1}
local invfact = {1}
for i = 2, 2000000 do
  fact[i] = bmul(fact[i - 1], i)
  invs[i] = bmul(mfl(mod / i), mod - invs[mod % i])
  invfact[i] = bmul(invfact[i - 1], invs[i])
end

local function getCombQ(n, k)
  if k == 0 or k == n then return 1 end
  return bmul(fact[n], bmul(invfact[k], invfact[n - k]))
end

local pow25 = {1}
local pow26 = {1}
for i = 2, 1000010 do
  pow25[i] = bmul(pow25[i - 1], 25)
  pow26[i] = bmul(pow26[i - 1], 26)
end

local k = io.read("*n", "*l")
local s = io.read()
local n = #s
local ret = 0
for j = 0, k do
  local z = getCombQ(n + j - 1, n - 1)
  z = bmul(z, pow25[j + 1])
  local rem = k - j
  z = bmul(z, pow26[rem + 1])
  ret = badd(ret, z)
end
print(ret)