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 C# (.NET Core 3.1.201) (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.Abc171
{
    public class ModularCombinationFixedK
    {
        int k;
        long mod;
        long[] combination;

        public ModularCombinationFixedK(int maxN, int k, long mod)
        {
            combination = new long[maxN + 1];
            this.k = k;
            this.mod = mod;

            combination[k] = 1;
            for (int i = k; i < maxN; i++)
                combination[i + 1] = combination[i] * (i + 1) % mod * Inverse(i - k + 1) % mod;
        }

        public ModularCombinationFixedK(int n, long mod) : this(n, n, mod) { }

        public long Get(int n)
        {
            return combination[n];
        }

        long Inverse(long a)
        {
            long i = mod, v = 0, d = 1;
            while (a > 0)
            {
                long t = i / a, x = a;
                a = i % x;
                i = x;
                x = d;
                d = v - t * x;
                v = x;
            }
            v %= mod;
            if (v < 0) v = (v + mod) % mod;
            return v;
        }
    }

    class F
    {
        static readonly long mod = 1000000007;

        public static void Main()
        {
            var k = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();

            int n = k + s.Length;

            var comb = new ModularCombinationFixedK(n - 1, s.Length - 1, mod);
            long ans = 0;

            var pow26 = new long[k + 1];
            pow26[0] = 1;
            for (int i = 1; i <= k; i++)
                pow26[i] = (pow26[i - 1] * 26) % mod;

            long pow25 = 1;
            for (int i = 0; i <= k; i++)
            {
                ans = (ans + (comb.Get(s.Length - 1 + i) * pow25) % mod * pow26[k - i]) % mod;
                pow25 = pow25 * 25 % mod;
            }
            Console.WriteLine(ans);
        }
    }
}