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;

const MOD:i64 = 1_000_000_007;

fn main() {
    input!{
        k:usize,
        s:String,
    };

    let n = s.len();

    let mut ans:i64 = 0;

    let mut fact = vec![1i64;n+k+1];
    for i in 0..n+k {
        fact[i+1] = fact[i]*((i+1) as i64)%MOD;
    }

    let powm = |mut x,mut k| {
        let mut res = 1;
        while k>0 {
            if k&1==1 {
                res = res*x%MOD;
            }
            k>>=1;
            x=x*x%MOD;
        }
        res
    };
    let mod_inv = |x| {
        powm(x,MOD-2)
    };
    let comb = |n,k| {
        fact[n] * mod_inv(fact[n-k]) %MOD * mod_inv(fact[k])%MOD
    };
    for i in 0..k {
        let pat = comb(n+k-i-1,n-1)*powm(25,(k-i) as i64)%MOD*powm(26,i as i64)%MOD;
        ans+=pat;
        ans%=MOD;
    }
    ans+=powm(26,k as i64);
    ans%=MOD;

    println!("{}",ans);
    
    

    


}