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 std::io;
use std::str::FromStr;

static MOD: u64 = 1_000_000_007;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn binary_power(x: u64, n: u64) -> u64 {
    if n == 0 {
      return 1;
    }
    if n % 2 == 0 {
      return (binary_power(x, n / 2) % MOD).pow(2) % MOD;
    } else {
      return binary_power(x, n - 1) % MOD * x % MOD;
    }
}
  
fn inverse_mod(n: u64) -> u64 {
    binary_power(n, MOD-2)
}  

fn combination(fact: &Vec<u64>, n: u64, m: u64) -> u64 {
    fact[n as usize] * inverse_mod(fact[(n-m) as usize]) %MOD * inverse_mod(fact[m as usize])%MOD
}

fn main() {
    let k: u64 = input();
    let s: String = input();
    let s: Vec<char> = s.chars().collect();
    let n = s.len() as u64;
    let mut fact: Vec<u64> = Vec::new();
    fact.push(1);
    for i in 1..n+k {
        fact.push(fact[i as usize - 1]*(i) % MOD);
    }

    let mut ans = 0;
    let mut comb = 1;
    for i in 0..(k + 1) {
        // println!("{}C{} * 25 ^ {} * 26 ^ {}", i+n-1, n-1, i, k-i);
        // println!("= {}", combination(i + n - 1, n - 1) % MOD * binary_power(25, i) % MOD * binary_power(26, k - i) % MOD);
        ans += combination(&fact, i + n - 1, n - 1) % MOD * binary_power(25, i) % MOD * binary_power(26, k - i) % MOD;
        ans %= MOD;

        comb = comb * (i + n + 2) % MOD * inverse_mod(n-1) % MOD;
    }
    // println!("{}", combination(1, 0));
    println!("{}", ans);
}