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

use proconio::{input, fastout};
static MODC: u64 = 1000000007;

fn powm (xx: u64, yy: u64) -> u64 {
    let mut x = xx;
    let mut y = yy;
    let mut result = 1;
    while y > 0 {
        if y & 1 != 0 {
            result *= x;
            result %= MODC;
        }
        x *= x;
        x %= MODC;
        y >>= 1;
    }
    result
}
fn combm (n: u64, k: u64) -> u64 {
    let mut x = n;
    let mut y = k;
    let mut result = 1;
    for _ in 0..k {
        result *= x * powm(y, MODC - 2) % MODC;
        result %= MODC;
        x -= 1;
        y -= 1;
    }
    result
}

#[fastout]
fn main() {
    input! {
        k: u64,
        s: String,
    }
    let n = s.len() as u64;
    let mut ans = 0;
    for i in 0..(k+1) {
        ans += powm(25, i) * powm(26, k - i) % MODC * combm(n + i - 1, n - 1) % MODC;
        ans %= MODC;
    }
    println!("{}", ans);
}