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: Time Limit Exceeded)

input = defined?(DATA) ? DATA : STDIN
k = input.gets.to_i
s = input.gets.chomp
n = s.length

class Integer
  def factorial
    return 1 if self.zero?
    (1..self).inject(:*)
  end

  def permutation(k)
    return 1 if k.zero?
    (self - k + 1..self).inject(:*)
  end

  def combination(k)
    return 1 if k.zero?
    k = self - k if self - k < k
    self.permutation(k) / k.factorial
  end
end

M = 10 ** 9 + 7

count = 0
(0..k).each do |i|
  count += 25.pow(k - i, M) * ((k + n - i - 1).combination(n - 1) % M) * 26.pow(i, M) % M
end

puts count % M