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 Fortran (GNU Fortran 9.2.1) (judge verdict: Time Limit Exceeded)

module module_swap
    use, intrinsic :: iso_fortran_env
    implicit none
    private
    public swap

    interface swap
        module procedure swap_scalar
    end interface

contains

    subroutine swap_scalar( lhs, rhs )
        class(*) :: lhs, rhs
        class(*), allocatable :: tmp, a, b

        allocate(a, source = lhs)
        allocate(b, source = rhs)

        call move_alloc(b, tmp)
        call move_alloc(a, b)
        call move_alloc(tmp, a)
        call bytes_to_anything(a, lhs)
        call bytes_to_anything(b, rhs)

    contains

        subroutine bytes_to_anything(bytes, anything)
            class(*) :: bytes
            class(*) :: anything

            select type(anything)
            type is ( character(*) )
                anything = transfer(bytes, anything)
            type is ( complex(real32) )
                anything = transfer(bytes, anything)
            type is ( complex(real64) )
                anything = transfer(bytes, anything)
            type is ( integer(int8) )
                anything = transfer(bytes, anything)
            type is ( integer(int16 ))
                anything = transfer(bytes, anything)
            type is ( integer(int32) )
                anything = transfer(bytes, anything)
            type is ( integer(int64) )
                anything = transfer(bytes, anything)
            type is ( real(real32) )
                anything = transfer(bytes, anything)
            type is ( real(real64) )
                anything = transfer(bytes, anything)
            type is ( real(real128) )
                anything = transfer(bytes, anything)
            class default
                stop 'bytes_to_anything(1) does not know about this type'
            end select

        end subroutine bytes_to_anything

    end subroutine swap_scalar

end module module_swap



module module_modint
    use, intrinsic :: iso_fortran_env
    use module_swap
    implicit none
    private
    public :: modint, set_modulus, modulo_utils, permutation, combination, homo

    type modint
        private
        integer(int64) :: val
    contains
        procedure :: n => get
        procedure :: add
        procedure :: sub
        procedure :: mul
        procedure :: inv
        procedure :: div
        procedure :: pow
        generic :: operator(+) => add
        generic :: operator(-) => sub
        generic :: operator(*) => mul
        generic :: operator(/) => div
        generic :: operator(**) => pow
    end type

    integer(int64) :: modulus = 1000000007
    type(modint), allocatable :: f(:), invf(:)

    interface modint
        module procedure :: init_modint
    end interface modint

    interface modulo_utils
        module procedure :: init_modulo_utils
    end interface modulo_utils

contains

    integer(int64) function mval(i) result(res)
        integer(int64), intent(in) :: i

        if ( (0_int64 <= i) .and. (i < modulus) ) then
            res = i
        else
            res = modulo(i, modulus)
        endif

    end function mval

    integer(int64) function to_int64(i) result(res)
        class(*), intent(in) :: i

        select type(i)
        type is (integer(int64))
            res = int(i, int64)
        type is (integer(int32))
            res = int(i, int64)
        type is (integer(int16))
            res = int(i, int64)
        type is (integer(int8))
            res = int(i, int64)
        end select

    end function to_int64


    subroutine set_modulus(m)
        class(*), intent(in) :: m

        select type(m)
        type is (modint)
            modulus = m%val
        class default
            modulus = to_int64(m)
        end select

    end subroutine set_modulus


    type(modint) function init_modint(i) result(res)
        class(*), intent(in) :: i

        select type(i)
        type is (modint)
            res%val = i%val
        class default
            res%val = mval( to_int64(i) )
        end select

    end function init_modint


    function get(this) result(res)
        class(modint), intent(in) :: this
        integer(int64) :: res

        res = this%val

    end function get


    type(modint) function add(this, other) result(res)
        class(modint), intent(in) :: this
        type(modint), intent(in) :: other

        res%val = mval( this%val + other%val )

    end function add


    type(modint) function sub(this, other) result(res)
        class(modint), intent(in) :: this
        type(modint), intent(in) :: other

        res%val = mval( this%val - other%val )

    end function sub


    type(modint) function mul(this, other) result(res)
        class(modint), intent(in) :: this
        type(modint), intent(in) :: other

        res%val = mval( this%val * other%val )

    end function mul


    type(modint) function div(this, other) result(res)
        class(modint), intent(in) :: this
        type(modint), intent(in) :: other

        res = this%mul( other%inv() )

    end function div


    type(modint) function inv(this) result(res)
        implicit none
        class(modint), intent(in) :: this
        integer(int64) :: a, b, u, v, t

        a = this%val
        b = modulus
        u = 1
        v = 0

        do while ( b /= 0 )
            t = a / b
            a = a - t * b
            call swap(a, b)
            u = u - t * v
            call swap(u, v)
        enddo

        res%val = modulo(u, modulus)

    end function inv

    type(modint) function pow(this, other) result(res)
        implicit none
        class(modint), intent(in) :: this
        class(*), intent(in) :: other
        integer(int64) :: n, k
        type(modint) :: i

        res%val = mval( to_int64(1) )
        i%val = this%val
        n = to_int64(other)

        do k = 1, abs(n)
            res = res%mul(i)
        enddo

        if ( n < 0) then
            res = modint(1) / res
        endif

    end function pow


    subroutine init_modulo_utils(i)
        class(*), intent(in) :: i
        integer(int64) :: k, n

        if ( allocated(f) ) deallocate(f)
        if ( allocated(invf) ) deallocate(invf)

        select type(i)
        type is (modint)
            n = i%val
        class default
            n = to_int64(i)
        end select

        allocate( f(0:n) )
        allocate( invf(0:n) )

        f(0) = modint(1)
        do k = 1, n
            f(k) = f(k-1) * modint(k)
        enddo

        invf(n) = f(n)%inv()
        do k = n, 1, -1
            invf(k-1) = invf(k) * modint(k)
        enddo

    end subroutine init_modulo_utils

    type(modint) function permutation(n, k)
        class(*), intent(in) :: n, k
        integer(int64) :: nt, kt

        select type(n)
        type is (integer(int64))
            nt = n
        class default
            nt = to_int64(n)
        end select

        select type(k)
        type is (integer(int64))
            kt = k
        class default
            kt = to_int64(k)
        end select

        if ( (kt > nt) .or. (nt < 0) .or. (kt < 0) ) return
        permutation = f(nt) * invf(nt-kt)

    end function permutation


    type(modint) function combination(n, k)
        class(*), intent(in) :: n, k
        integer(int64) :: nt, kt

        select type(n)
        type is (integer(int64))
            nt = n
        class default
            nt = to_int64(n)
        end select

        select type(k)
        type is (integer(int64))
            kt = k
        class default
            kt = to_int64(k)
        end select

        combination = permutation(nt, kt) * invf(kt)

    end function combination


    type(modint) function homo(n, k)
        class(*), intent(in) :: n, k
        integer(int64) :: nt, kt

        select type(n)
        type is (integer(int64))
            nt = n
        class default
            nt = to_int64(n)
        end select

        select type(k)
        type is (integer(int64))
            kt = k
        class default
            kt = to_int64(k)
        end select

        homo = modint(1)
        if ( (nt == 0) .and. (kt == 0) ) return
        homo = combination(nt+kt-1, kt)

    end function homo

end module module_modint




program main
    use,intrinsic :: iso_fortran_env
    use :: module_modint
    implicit none

    integer(int64) :: div, k, n, i
    character(10**6) :: s
    type(modint) :: ans

    div = 10**9 + 7
    ans = modint(0)

    call set_modulus(div)

    read *, k
    read *, s

    n = len_trim(s)
    call modulo_utils( n+k )

    do i = 0, k
        ans = ans + (modint(25) ** ( k-i )) * combination( n+k-i-1, n-1 ) * (modint(26) ** i)
    enddo
    
    print *, ans%n()

end program main