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 PHP (7.4.4) (judge verdict: Time Limit Exceeded)

<?php
define('MOD', 10 ** 9 + 7);
list($k) = ints();
list($s) = strs();
$ls = strlen($s);
init($ls + $k - 1);
$ans = 0;
for ($i = 0; $i <= $k; ++$i) {
    $cnt = (nCr2($ls + $k - $i - 1, $ls - 1) * modPow(25, $k - $i) % MOD) * modPow(26, $i) % MOD;
    $ans = ($ans + $cnt) % MOD;
}
echo $ans;
function strs()
{
    return explode(' ', trim(fgets(STDIN)));
}
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
// 足し算
function modAdd($x, $y)
{
    return ($x + $y) % MOD;
}

// 引き算
function modSub($x, $y)
{
    return ($x + MOD - $y) % MOD;
}

// 掛け算
function modMul($x, $y)
{
    return ($x * $y) % MOD;
}

// 割り算
function modDiv($x, $y)
{
    return modMul($x, modPow($y, MOD - 2));
}

// 累乗（繰り返し二乗法）
function modPow($n, $x)
{
    if ($x === 0) return 1;
    $res = (modPow($n, $x >> 1) ** 2) % MOD;
    if ($x % 2 === 1) $res = modMul($res, $n);
    return $res;
}

// 階乗
function modFac($n)
{
    if ($n === 0) return 1;
    return modMul($n, modFac($n - 1));
}

// 順列
function nPr($n, $r)
{
    if ($r === 0) return 1;
    return modMul(nPr($n, $r - 1), $n - $r + 1);
}

// 組み合わせ
function nCr($n, $r)
{
    $r = min($r, $n - $r);
    if ($r === 0) return 1;
    return modDiv(nPr($n, $r), modFac($r));
}

// 階乗、逆元を前処理
function init($max)
{
    global $fac, $finv, $inv;
    $fac = $finv = [1, 1];
    $inv[1] = 1;
    for ($i = 2; $i <= $max; ++$i) {
        $fac[$i] = $fac[$i - 1] * $i % MOD;
        $inv[$i] = MOD - $inv[MOD % $i] * intdiv(MOD, $i) % MOD;
        $finv[$i] = $finv[$i - 1] * $inv[$i] % MOD;
    }
}

// 組み合わせ(前処理利用）
function nCr2($n, $r)
{
    global $fac, $finv;
    $r = min($r, $n - $r);
    if ($r === 0) return 1;
    return $fac[$n] * ($finv[$r] * $finv[$n - $r] % MOD) % MOD;
}