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: Runtime Error)

import java.io.*
import java.util.*
import kotlin.math.*

fun main(){
	val f = BufferedReader(InputStreamReader(System.`in`))

	val i = f.readLine().toInt()
	val s = f.readLine()
	val n1 = s.length

	//CHECK THE MOD!!!
	val MOD : Long = 1000000007L
	val fac = LongArray(1000005)
	fac[0] = 1L
	for(k in 1 until 1000005){
		fac[k] = (fac[k-1]*k.toLong() + MOD)%MOD
	}

	fun exp(base : Long, power : Long) : Long{
		if(power == 0L) return 1L
		if(power == 1L) return (base + MOD)%MOD
		var ans = exp(base,power/2)
		ans = (ans*ans + MOD)%MOD
		if(power%2 == 1L) ans = (ans*base + MOD)%MOD
		return (ans + MOD)%MOD
	}
	fun modInverse(n : Long, p : Long) : Long{
		return exp(n,p-2)
	}
	fun choose (n : Int, r : Int) : Long{
		if(r == 0) return 1L
		if(n < r) return 0L
		return (((fac[n.toInt()] * modInverse(fac[r.toInt()], MOD) + MOD) % MOD) * modInverse(fac[(n-r).toInt()], MOD) + MOD) % MOD;
	}

	val pow25 = LongArray(1000005)
	val pow26 = LongArray(1000005)

	pow25[0] = 1L
	pow26[0] = 1L

	for(k in 1 until 1000005){
		pow25[k] = (pow25[k-1]*25L + MOD)%MOD
		pow26[k] = (pow26[k-1]*26L + MOD)%MOD
	}

	var answer = 0L

	for(k in 0..i){
		val prod1 = (pow26[i-k]*pow25[k] + MOD)%MOD
		val prod2 = (prod1 * (choose(k+n1-1,k)) + MOD)%MOD
		answer = (answer + prod2 + MOD)%MOD
	}

	println(answer)

}