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)

// This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder)
// Original source code:
/*
use competitive::prelude::*;

type GF = competitive::gf::GF<promote!(1000_000_007)>;

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

    // for a in 1..10 {
    //     for b in 1..10 {
    //         echo!(a, b, solve(0, 0, a + b, &vec!['0'; b]));
    //         solve_reset();
    //     }
    // }

    // let ans = solve(0, 0, k + s.len(), &s);
    // echo!(ans);

    let ans = solve2(k, s.len());
    echo!(ans);
}

#[memoise(i, j)]
fn solve(i: usize, j: usize, n: usize, s: &[char]) -> GF {
    if i == n {
        return if j == s.len() { 1 } else { 0 }.into();
    }

    let mut ret = GF::new(0);

    if j < s.len() {
        ret += solve(i + 1, j + 1, n, s);
        ret += solve(i + 1, j, n, s) * 25;
    } else {
        ret += solve(i + 1, j, n, s) * 26;
    }

    ret
}

use competitive::number::*;

fn solve2(a: usize, b: usize) -> GF {
    let mut fact = vec![GF::new(1); a + b + 1];

    for i in 1..fact.len() {
        fact[i] = fact[i - 1] * i;
    }

    let mut ret = GF::new(0);

    for i in 0..=a + b {
        let t = if i < b { 0 } else { 1 };
        ret += t * comb_from_table(a + b, i, &fact) * GF::new(25).pow((a + b - i) as _);
    }

    ret
}
*/

fn main() {
    let exe = "/tmp/binAC066212";
    std::io::Write::write_all(&mut std::fs::File::create(exe).unwrap(), &decode(BIN)).unwrap();
    std::fs::set_permissions(exe, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
    std::process::exit(std::process::Command::new(exe).status().unwrap().code().unwrap())
}

fn decode(v: &str) -> Vec<u8> {
    let mut ret = vec![];
    let mut buf = 0;
    let mut tbl = vec![64; 256];
    for i in 0..64 { tbl[TBL[i] as usize] = i as u8; }
    for (i, c) in v.bytes().filter_map(|c| { let c = tbl[c as usize]; if c < 64 { Some(c) } else { None } }).enumerate() {
        match i % 4 {
            0 => buf = c << 2,
            1 => { ret.push(buf | c >> 4); buf = c << 4; }
            2 => { ret.push(buf | c >> 2); buf = c << 6; }
            3 => ret.push(buf | c),
            _ => unreachable!(),
        }
    }
    ret
}

const TBL: &'static [u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const BIN: &'static str = "<base64-encoded ELF executable removed>";