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 Kotlin (1.3.71) (judge verdict: Accepted)

import java.io.BufferedReader
import java.io.InputStreamReader

const val MOD = 1000000007L
val INV_26 = 26L pow -1

fun main() {
    val jin = BufferedReader(InputStreamReader(System.`in`))
    val k = jin.readLine().toInt()
    val n = jin.readLine().length
    var answer = 0L
    var curr = 26L pow k
    for (j in n..n + k) {
        answer += curr
        curr *= (j + 1 - n).toLong() pow -1
        curr %= MOD
        curr *= INV_26
        curr %= MOD
        curr *= j.toLong()
        curr *= 25L
        curr %= MOD
    }
    println(answer % MOD)
}

val MOD_TOTIENT = (MOD - 1).toInt()

infix fun Long.pow(power: Int): Long {
    var e = power
    e %= MOD_TOTIENT
    if (e < 0) {
        e += MOD_TOTIENT
    }
    if (e == 0 && this == 0L) {
        return this
    }
    var b = this % MOD
    var res = 1L
    while (e > 0) {
        if (e and 1 != 0) {
            res *= b
            res %= MOD
        }
        b *= b
        b %= MOD
        e = e shr 1
    }
    return res
}