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 Ruby (2.7.1) (judge verdict: Accepted)

K = gets.to_i
SL = gets.chomp.length
s = SL-1

M = 10**9+7

fact = [1]
1.upto(K+s) do |i|
    fact[i] = (fact[i-1]*i) % M
end

def pow(a,b)
    ret = 1
    while b>0
        ret = ret * a % M if b & 1 != 0
        a = a*a % M
        b = b >> 1
    end
    ret
end

fact_inv = [nil] * fact.size
fact_inv[-1] = pow(fact[-1], M-2)
(K+s).downto(1) do |i|
    fact_inv[i-1] = fact_inv[i] * i % M
end

comb = ->(a,b){fact[a] * fact_inv[a-b] * fact_inv[b] % M}

pow25 = [1]
pow26 = [1]
1.upto(K) do |i|
    pow25[i] = pow25[i-1]*25 % M
    pow26[i] = pow26[i-1]*26 % M
end

ans = 0
0.upto(K) do |i|
    c = comb.(s+i,i)
    ans = (ans + c*pow25[i] * pow26[K-i]) % M
end

puts ans % M