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, fastout};
const 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
}
struct Fact {
    mm: Vec<u32>,
    iv: Vec<u32>,
}
impl Fact {
    fn new() -> Fact {
        Fact {
            mm: vec![1],      // idx!
            iv: vec![powm(1, MODC - 2) as u32],     // 1 / idx!
        }

    }
    fn fact(&mut self, x: u64) -> u64 {
        if x < self.mm.len() as u64 { self.mm[x as usize] as u64 }
        else {
            let len = self.mm.len();
            let mut n = self.mm[len-1] as u64;
            for i in (len as u64)..(x + 1) {
                n = n * i % MODC;
                self.mm.push(n as u32);
            }
            n
        }
    } 
    fn facti(&mut self, x: u64) -> u64 {
        if x < self.iv.len() as u64 { self.iv[x as usize] as u64 }
        else {
            let len = self.iv.len();
            let mut n: u64 = 0;
            for i in (len as u64)..(x + 1) {
                n = powm(self.fact(i), MODC - 2);
                self.iv.push(n as u32);
            }
            n
        }
    } 
    fn combm (&mut self, n: u64, k: u64) -> u64 {
        let mut result = self.fact(n);
        result = result * self.facti(n - k) % MODC;
        result * self.facti(k) % MODC
    }
}

#[fastout]
fn main() {
    let mut f = Fact::new();
    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 * f.combm(n + i - 1, n - 1) % MODC;
        if ans >= MODC {ans -= MODC};
    }
    println!("{}", ans);
}