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

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(n: u64, mut m: u64) -> u64 {
    if n < m {
        return 0;
    }
    
    if m > n - m {
        m = n - m
    }

    let mut ret = 1u64;
    for i in 0..m {
        ret %= MOD;
        ret *= n - i;        
    }
    ret %= MOD;

    let mut div = 1u64;
    for i in 1..(m+1) {
        div %= MOD;
        div *= i;
    }
    div %= MOD;

    // println!("{}, {}", ret, div);
    ret * inverse_mod(div) % 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 ans = 1u64;
    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 += comb % MOD * binary_power(25, i) % MOD * binary_power(26, k - i) % MOD;
        // println!("{}", i+k);
        comb *= (i + n) % MOD;
        comb /= (i + n - 2) % MOD;
        ans %= MOD;
    }
    // println!("{}", combination(1, 0));
    println!("{}", ans - 1);
}