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)

MOD = 10**9 + 7
k = gets.to_i
s = gets.chomp
size = s.size

@fac = [1, 1]
@finv = [1, 1]
@inv = [1, 1]

2.upto(2 * 10**6) do |i|
  @fac[i] = @fac[i - 1] * i % MOD
  @inv[i] = MOD - @inv[MOD % i] * (MOD / i) % MOD
  @finv[i] = @finv[i - 1] * @inv[i] % MOD
end

def com(n, k)
  return 0 if n < k || n < 0 || k < 0
  @fac[n] * (@finv[k] * @finv[n - k] % MOD) % MOD
end

pow25 = Array.new(k + 1)
pow26 = Array.new(k + 1)
pow25[0] = pow26[0] = 1

k.times do |i|
  pow25[i + 1] = pow25[i] * 25 % MOD
  pow26[i + 1] = pow26[i] * 26 % MOD
end

ret = 0
0.upto(k) do |i|
  ret += com(i + size - 1, size - 1) * pow25[i] * pow26[k - i] % MOD
end

puts ret % MOD