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(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

struct Comb {
    div: usize,
    g1: Vec<usize>,
    g2: Vec<usize>,
}
impl Comb {
    #[allow(dead_code)]
    fn new(nmax: usize) -> Self {
        let mut g1 = vec![1; nmax + 1];
        let mut g2 = vec![1; nmax + 1];
        let mut inv = vec![0; nmax + 1];
        inv[1] = 1;
        let div = 1000000007;
        for i in 2..(nmax + 1) {
            g1[i] = g1[i - 1] * i % div;
            inv[i] = div - (inv[div % i] * (div / i)) % div;
            g2[i] = (g2[i - 1] * inv[i]) % div;
        }
        Comb {
            div: div,
            g1: g1,
            g2: g2,
        }
    }
    #[allow(dead_code)]
    fn compute(&self, n: usize, k: usize) -> usize {
        (((self.g1[n] * self.g2[k]) % self.div) * self.g2[n - k]) % self.div
    }
    #[allow(dead_code)]
    fn compute_dupc(&self, n: usize, k: usize) -> usize {
        self.compute(n + k - 1, n - 1)
    }
    #[allow(dead_code)]
    fn compuute_perm(&self, n: usize, k: usize) -> usize {
        (self.g1[n] * self.g2[n - k]) % self.div
    }
}

use self::modint::ModInt;
mod modint {
    use std;
    #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
    pub struct ModInt(usize);
    impl ModInt {
        pub fn new(value: usize) -> Self {
            ModInt(value % Self::modulo())
        }
        fn modulo() -> usize {
            1_000_000_007
        }
        pub fn pow(&self, n: usize) -> Self {
            let mut res = ModInt::new(1);
            let mut beki = *self;
            let mut n = n;
            while n > 0 {
                if n % 2 == 1 {
                    res *= beki;
                }
                beki *= beki;
                n /= 2;
            }
            res
        }
    }
    impl std::ops::Add for ModInt {
        type Output = Self;
        fn add(self, other: Self) -> Self {
            let mut value = self.0 + other.0;
            if value > Self::modulo() {
                value -= Self::modulo();
            }
            ModInt::new(value)
        }
    }
    impl std::ops::Add<usize> for ModInt {
        type Output = Self;
        fn add(self, other: usize) -> Self {
            let other = ModInt::new(other);
            self + other
        }
    }
    impl std::ops::Sub for ModInt {
        type Output = Self;
        fn sub(self, other: Self) -> Self {
            let mut value = self.0;
            if value < other.0 {
                value += Self::modulo();
            }
            value -= other.0;
            ModInt::new(value)
        }
    }
    impl std::ops::Sub<usize> for ModInt {
        type Output = Self;
        fn sub(self, other: usize) -> Self {
            let other = ModInt::new(other);
            self - other
        }
    }
    impl std::ops::Mul for ModInt {
        type Output = Self;
        fn mul(self, other: Self) -> Self {
            let value = self.0 * other.0 % Self::modulo();
            ModInt::new(value)
        }
    }
    impl std::ops::Mul<usize> for ModInt {
        type Output = Self;
        fn mul(self, other: usize) -> Self {
            let other = ModInt::new(other);
            self * other
        }
    }
    impl std::ops::Mul<ModInt> for usize {
        type Output = ModInt;
        fn mul(self, other: ModInt) -> Self::Output {
            let value = ModInt::new(self);
            value * other
        }
    }
    impl std::ops::Div for ModInt {
        type Output = Self;
        fn div(self, other: Self) -> Self {
            let mut exp = Self::modulo() - 2;
            let mut value = self.0;
            let mut ovalue = other.0;
            while exp > 0 {
                if exp % 2 == 1 {
                    value = value * ovalue % Self::modulo();
                }
                ovalue = ovalue * ovalue % Self::modulo();
                exp /= 2;
            }
            ModInt::new(value)
        }
    }
    impl std::ops::Div<usize> for ModInt {
        type Output = Self;
        fn div(self, other: usize) -> Self {
            let other = ModInt::new(other);
            self / other
        }
    }
    impl std::ops::AddAssign for ModInt {
        fn add_assign(&mut self, other: Self) {
            *self = *self + other;
        }
    }
    impl std::ops::AddAssign<usize> for ModInt {
        fn add_assign(&mut self, other: usize) {
            *self = *self + other;
        }
    }
    impl std::ops::SubAssign for ModInt {
        fn sub_assign(&mut self, other: Self) {
            *self = *self - other;
        }
    }
    impl std::ops::SubAssign<usize> for ModInt {
        fn sub_assign(&mut self, other: usize) {
            *self = *self - other;
        }
    }
    impl std::ops::MulAssign for ModInt {
        fn mul_assign(&mut self, other: Self) {
            *self = *self * other;
        }
    }
    impl std::ops::MulAssign<usize> for ModInt {
        fn mul_assign(&mut self, other: usize) {
            *self = *self * other;
        }
    }
    impl std::ops::DivAssign for ModInt {
        fn div_assign(&mut self, other: Self) {
            *self = *self / other;
        }
    }
    impl std::ops::DivAssign<usize> for ModInt {
        fn div_assign(&mut self, other: usize) {
            *self = *self / other;
        }
    }
    impl std::fmt::Debug for ModInt {
        fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
            write!(f, "{}", self.0)
        }
    }
    impl std::fmt::Display for ModInt {
        fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
            write!(f, "{}", self.0)
        }
    }
}

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

    let n = s.len();
    let mut base = ModInt::new(1);
    let comb = Comb::new(n + k);
    let mut res = ModInt::new(0);
    for i in 0..k + 1 {
        res += base * comb.compute(n + k, i);
        base *= 25;
    }
    println!("{}", res);
}