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)

# frozen_string_literal: true

k = gets.to_i
s = gets.chomp
n = s.size

M = (10**9 + 7)

# https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a#5-%E4%BA%8C%E9%A0%85%E4%BF%82%E6%95%B0-ncr
@fac = [1, 1]
@finv = [1, 1]
@inv = [1, 1]

2.upto(k + n) do |i|
  @fac[i] = (@fac[i - 1] * i) % M
  @inv[i] = M - @inv[M % i] * (M / i) % M
  @finv[i] = @finv[i - 1] * @inv[i] % M
end

def nCk(n, k)
  return 0 if n < k || n < 0 || k < 0

  @fac[n] * (@finv[k] * @finv[n - k] % M) % M
end

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

ans = 0
0.upto(k) do |i|
  ans += ((pow26[k - i] * pow25[i] % M) * nCk(i + n - 1, i)) % M
  ans %= M
end
puts ans