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;
using System.Text;
using System.Threading.Tasks;

namespace ProblemF
{
    class Program
    {
        public static long div = 1000000007;

        static void Main(string[] args)
        {
            var K = long.Parse(Console.ReadLine());
            var S = (Console.ReadLine());
            long N = (long)S.Length;
            long[] pow25s = new long[K + 1];
            long[] pow26s = new long[K + 1];
            pow25s[0] = 1;
            pow26s[0] = 1;
            for (int i = 1; i < K + 1; i++)
            {
                pow25s[i] = (25 * pow25s[i - 1]) % div;
                pow26s[i] = (26 * pow26s[i - 1]) % div;
            }

            long combination = 1;
            long res = 0;
            for (long i = K; i >= 0; i--)
            {
                if(i != K)
                {
                    combination = combination * (N + K - i - 1);
                    combination %= div;
                    combination *= modinv(K - i, div);
                    combination %= div;
                }
                var resTemp = combination * pow25s[K - i];
                resTemp %= div;
                resTemp *= pow26s[i];
                resTemp %= div;
                res += resTemp;
                res %= div;
            }
            Console.WriteLine(res);



            #region 
            //var dp = new long[K + 1];
            //dp[0] = 1;
            //for (int i = 1; i < K + 1; i++)
            //{
            //    dp[i] = dp[i - 1];
            //    dp[i] *= ((len + 1) * 26 - len) % div;
            //    dp[i] %= div;
            //    len++;
            //}
            //Console.WriteLine(dp[K]);
            #endregion
        }

        static long nCm(long n, long m)
        {
            try
            {
                if (n == 0) return 0;
                if (m == 0) return 1;
                return checked(((n * nCm(n - 1, m - 1)) % div) / m);
            }
            catch(OverflowException)
            {
                throw new OverflowException();
            }
        }

        // return inverse num of a with mod m
        public static long modinv(long a, long m)
        {
            long b = m, u = 1, v = 0;
            while (b > 0)
            {
                long t = a / b;
                a -= t * b;
                var temp = a;
                a = b;
                b = temp;
                u -= t * v;
                temp = u;
                u = v;
                v = temp;
            }
            u %= m;
            if (u < 0) u += m;
            return u;
        }
    }
}