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: Accepted)

use proconio::input;
use proconio::marker::Chars;

fn mypow(a: u64, b: u64, md: u64) -> u64 {
    if b == 0 {
        1
    } else {
        let tmp = mypow(a, b / 2, md);
        if b % 2 == 1 {
            (((tmp * tmp) % md) * a) % md
        } else {
            (tmp * tmp) % md
        }
    }
}

fn main() {
    input! {
        k: usize,
        s: Chars,
    }
    let n = k + s.len();
    let md = 1000000007;
    let max_n = 2000010;
    let mut fact = vec![1 as u64; max_n];
    let mut inv = vec![1 as u64; max_n];
    fact[0] = 1;
    for i in 2..max_n {
        fact[i] = fact[i - 1] * i as u64 % md;
        inv[i] = mypow(fact[i], md - 2, md);
    }
    let mut ans: u64 = 1;
    for _ in 0..n {
        ans *= 26;
        ans %= md;
    }
    let mut sum: u64 = 0;
    for i in 0..s.len() {
        let mut comb = fact[n] * inv[i] % md;
        comb = comb * inv[n-i] % md;
        //println!("i: {}, comb: {}", i, comb);
        sum += mypow(25 as u64, (n - i) as u64, md) * comb % md;
        sum %= md;
    }
    println!("{}", (ans + md - sum) % md);
}