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)

#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
use proconio::input;
//use proconio::marker::Usize1;
use proconio::marker::Chars;
//use std::collections::HashSet;
// use std::cmp::*;

const M: u64 = 1000_000_007;

fn main() {
    input! {
        k:u64,
        s:Chars
    }
    let n = s.len();
    // 最後の文字以降におく文字数をiとすると、
    // 文字のえらび方は、25.pow(k-i)*26.pow(i)
    // また、n-1 文字の挿入位置は (k-i+n-1 choose n-1)
    // n choose k = n*(n-1)*...*(n-k+1) /(k*...*1) なので、
    // あとは、各iについて、合計すればよい。
    let mut fact = vec![1u64; 2_000_010];
    let mut inv_fact = vec![1u64; 2_000_010];
    let mut pow25 = vec![1u64; 1_000_010];
    let mut pow26 = vec![1u64; 1_000_010];
    fact[0] = 1;
    for i in 0..2_000_005 {
        fact[i + 1] = fact[i] * ((i + 1) as u64) % M;
        inv_fact[i] = modInv(fact[i]);
    }
    pow25[0] = 1;
    pow26[0] = 1;
    for i in 0..1000_001 {
        pow25[i + 1] = pow25[i] * 25 % M;
        pow26[i + 1] = pow26[i] * 26 % M;
    }
    let choose = |n, k| fact[n as usize] * inv_fact[n - k] % M * inv_fact[k] % M;
    // ここまでは計算の準備。
    let mut ans = 0u64;
    for i in 0..k + 1 {
        ans += choose(n + (k as usize) - (i as usize) - 1, n - 1) * pow25[(k - i) as usize] % M
            * pow26[i as usize]
            % M;
    }
    println!("{}", ans % M);
}
fn modPow(x: u64, a: u64) -> u64 {
    if a == 0 {
        1
    } else {
        if a == 1 {
            x
        } else {
            if a % 2 != 0 {
                (modPow(x, a - 1) * x) % M
            } else {
                let t = modPow(x, a / 2);
                t * t % M
            }
        }
    }
}
fn modInv(x: u64) -> u64 {
    modPow(x, M - 2)
}