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
}
static mut FACTRM_M: [u32; 1000001] = [MODC as u32; 1000001];
fn factrm(k: u64) -> u64 {
    unsafe {
        if FACTRM_M[k as usize] == MODC as u32 {
            let mut r = 1;
            if k > 1 {
                for i in 2..(k+1) {
                    r *= i;
                    r %= MODC;
                }
            }
            r = powm(r, MODC - 2);
            FACTRM_M[k as usize] = r as u32;
            r
        } else {
            FACTRM_M[k as usize] as u64            
        }
    }
}
fn combm (n: u64, k: u64) -> u64 {
    let mut x = n;
    let mut result = 1;
    for _ in 0..k {
        result *= x;
        result %= MODC;
        x -= 1;
    }
    result * factrm(k) % MODC
}

#[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);
}