Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###



def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    H,W=MI()
    A=[]
    A.append(list("#"*(W+2)))
    for i in range(H):
        A.append(list("#"+input()+"#"))
    A.append(list("#"*(W+2)))
    
    
    import queue
    q=queue.Queue()
    
    inf=-1
    dMap=[[inf]*(W+2)for _ in range(H+2)]
    for i in range(1,H+1):
        for j in range(1,W+1):
            if A[i][j]=="#":
                q.put((i,j,0))
                dMap[i][j]=0
                
    for i in range(H+2):
        dMap[i][0]=0
        dMap[i][-1]=0
        
    for j in range(W+2):
        dMap[0][j]=0
        dMap[-1][j]=0
        
    
    dx=[0,0,1,-1]
    dy=[1,-1,0,0]
    

    while not q.empty():
        ii,jj,d=q.get()
        for k in range(4):
            nxt_i=ii+dx[k]
            nxt_j=jj+dy[k]
            if dMap[nxt_i][nxt_j]==inf:
                q.put((nxt_i,nxt_j,d+1))
                dMap[nxt_i][nxt_j]=d+1
                
    ans=0
    for i in range(H+2):
        temp=max(dMap[i])
        ans=max(temp,ans)
    print(ans)
                
                
    
            

main()


### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]

black_idx = []
for h in range(H):
    for w in range(W):
        if A[h][w] == "#":
            black_idx.append([h,w])

distance = [[float("inf")]*W for _ in range(H)]
for b in black_idx:
    distance[b[0]][b[1]] = 0

d = deque(black_idx)
ans = 0

while d:
    y, x = d.popleft()
    for new_y, new_x in ([y+1, x], [y, x+1], [y-1, x], [y, x-1]):
        if 0 <= new_y <= H-1 and 0 <= new_x <= W-1 and distance[y][x] + 1 < distance[new_y][new_x]:
            distance[new_y][new_x] = distance[y][x] + 1
            ans = max(ans, distance[y][x] + 1)
            d.append([new_y, new_x])

print(ans)
### BUGGY CODE ###

N, M, P = map(int, input().split())
from collections import deque,defaultdict
edge1 = [[] for _ in range(N)]
edge2 = [[] for _ in range(N)]
for i in range(M):
    a,b,c= map(int, input().split())
    edge1[a-1].append([b-1,P-c])
    edge2[b-1].append([a-1,P-c])
edges1 = []
d = deque([0])
visited1 = defaultdict(lambda: False)
while len(d):
    v = d.popleft()
    for u,w in edge1[v]:
        if visited1[(w,v,u)] == False:
            visited1[(w,v,u)] = True
            edges1.append([w,v,u])
            d.append(u)
edges2 = []
d = deque([N-1])
visited2 = defaultdict(lambda: False)
while len(d):
    v = d.popleft()
    for u,w in edge2[v]:
        if visited2[(w,u,v)] == False:
            visited2[(w,u,v)] = True
            edges2.append([w,u,v])
            d.append(u)
new_edge = []
for e in edges1:
    if e in edges2:
        new_edge.append(e)
d = [10**10]*N
d[0] = 0
n = 0
while True:
    n += 1
    update = False
    for w,v,u in new_edge:
        if d[u]>d[v]+w:
            d[u] = d[v]+w
            update = True
    if update == False:
        break
    if n==N and update==True:
        print(-1)
        exit()
print(max(0,-d[-1]))

### FIXED CODE ###

N, M, P = map(int, input().split())
from collections import deque,defaultdict
edge1 = [[] for _ in range(N)]
edge2 = [[] for _ in range(N)]
for i in range(M):
    a,b,c= map(int, input().split())
    edge1[a-1].append([b-1,P-c])
    edge2[b-1].append([a-1,P-c])
edges1 = set()
d = deque([0])
visited1 = defaultdict(lambda: False)
while len(d):
    v = d.popleft()
    for u,w in edge1[v]:
        if visited1[w*10**8+v*10**4+u] == False:
            visited1[w*10**8+v*10**4+u] = True
            edges1.add(w*10**8+v*10**4+u)
            d.append(u)
edges2 = set()
d = deque([N-1])
visited2 = defaultdict(lambda: False)
while len(d):
    v = d.popleft()
    for u,w in edge2[v]:
        if visited2[w*10**8+u*10**4+v] == False:
            visited2[w*10**8+u*10**4+v] = True
            edges2.add(w*10**8+u*10**4+v)
            d.append(u)
new_edge = list(edges1&edges2)
d = [10**10]*N
d[0] = 0
n = 0
while True:
    n += 1
    update = False
    for e in new_edge:
        w = e//10**8
        v = e%10**8//10**4
        u = e%10**4
        if d[u]>d[v]+w:
            d[u] = d[v]+w
            update = True
    if update == False:
        break
    if n==N and update==True:
        print(-1)
        exit()
print(max(0,-d[-1]))
### BUGGY CODE ###

n = int(input())
li = list(map(int,input().split()))
lia = [0]*n
lib = [0]*n
for i in range(n):
    lia[li[i]-1] += 1
for i in range(n):
    if lia[i] >= 2:
        lia[i] -= 1
        lib[i] += (lia[i]*(lia[i]+1)//2)
for i in range(n):
    a = lib[li[i]-1]
    lib[li[i]-1] = (lia[li[i]-1]-1)*(lia[li[i]-1])//2
    print(sum(lib))
    lib[li[i]-1] = a

### FIXED CODE ###

n = int(input())
li = list(map(int,input().split()))
lia = [0]*n
sum1 = 0
for i in range(n):
    lia[li[i]-1] += 1
for i in range(n):
    if lia[i] >= 2:
        lia[i] -= 1
        sum1 += (lia[i]*(lia[i]+1)//2)
    else:
        if lia[i] == 1:
            lia[i] -= 1
for i in range(n):
    if lia[li[i]-1] >= 1:
        a = lia[li[i]-1]*(lia[li[i]-1]+1)//2
        b = (lia[li[i]-1]-1)*lia[li[i]-1]//2
        print(sum1-a+b)
    else:
        print(sum1)
### BUGGY CODE ###

from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())

grid = []
for i in range(H):
    grid.append(input().rstrip())

d = deque()
d.append((Ch-1, Cw-1, 0))

memo = [[[False] * W for _ in range(H)] for _ in range(1000)]
memo[0][Ch-1][Cw-1] = True

searched = [[False] * W for _ in range(H)]

ans = -1

while d:
    h, w, c = d.popleft()

    if searched[h][w]:
        continue

    searched[h][w] = True

    if h == Dh-1 and w == Dw-1:
        ans = c
        break

    for i, j in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
        if 0 <= h+i < H and 0 <= w+j < W:
            if grid[h+i][w+j] == '.':
                if not memo[c][h+i][w+j]:
                    memo[c][h+i][w+j] = True
                    d.appendleft((h+i, w+j, c))

    for i in range(-2, 3):
        for j in range(-2, 3):
            if 0 <= h+i < H and 0 <= w+j < W:
                if grid[h+i][w+j] == '.':
                    if not memo[c][h+i][w+j] and not memo[c+1][h+i][w+j] and not searched[h+i][w+j]:
                        memo[c+1][h+i][w+j] = True
                        d.append((h+i, w+j, c+1))

print(ans)


### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())

grid = []
for i in range(H):
    grid.append(input().rstrip())

d = deque()
d.append((Ch-1, Cw-1, 0))

memo = [[[False] * W for _ in range(H)] for _ in range(2)]
memo[0][Ch-1][Cw-1] = True

searched = [[False] * W for _ in range(H)]

ans = -1

while d:
    h, w, c = d.popleft()

    if searched[h][w]:
        continue

    searched[h][w] = True

    if h == Dh-1 and w == Dw-1:
        ans = c
        break

    for i, j in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
        if 0 <= h+i < H and 0 <= w+j < W:
            if grid[h+i][w+j] == '.':
                if not memo[0][h+i][w+j] and not searched[h+i][w+j]:
                    memo[0][h+i][w+j] = True
                    d.appendleft((h+i, w+j, c))

    for i in range(-2, 3):
        for j in range(-2, 3):
            if 0 <= h+i < H and 0 <= w+j < W:
                if grid[h+i][w+j] == '.':
                    if not memo[0][h+i][w+j] and not memo[1][h+i][w+j] and not searched[h+i][w+j]:
                        memo[1][h+i][w+j] = True
                        d.append((h+i, w+j, c+1))

print(ans)
### BUGGY CODE ###

N = int(input())
P = list(map(int, input().split()))

A = 0

for i in range(N):
  if P[i] <= min(P[0:i+1]):
  	A += 1
  if P[i] == 1:
    break
print(A)

### FIXED CODE ###

N = int(input())
P = list(map(int, input().split()))
 
A = 0
C = P[0]
for i in range(N):
  if P[i] <= C:
    C = P[i]
    A += 1
print(A)
### BUGGY CODE ###

n,k = map(int,input().split())
line = list(map(int,input().split()))
setted_line = list(set(line))
origin_num = len(setted_line) #種類
pairs = {}
for i in range(len(setted_line)):
  count = line.count(setted_line[i])
  pairs[setted_line[i]] = count
sorted_pairs = sorted(pairs.items(), key = lambda x:x[1])
answer = 0
if origin_num <= k:
  answer = 0
else:
  gap = origin_num - k #種類の差
  for j in range(gap):
    answer += sorted_pairs[j][1]
print(answer)

### FIXED CODE ###

import collections
n,k = map(int,input().split())
line = list(input().split())
c = collections.Counter(line)
answer = 0
if k > len(c):
  answer = 0
else:
  gap = len(c) - k
  sorted_c = list(sorted(c.items(),key = lambda x:x[1]))
  for i in range(gap):
    answer += int(sorted_c[i][1])
print(answer)
### BUGGY CODE ###

n = int(input())
c = input()

ar = c.count('R')
aw = c.count('W')

anses = []
for i in range(n + 1):
  rtow, wtor = 0, 0
  for j, e in enumerate(c):
    if j < i:
      if e != 'R':
        rtow += 1
    else:
      if e != 'W':
        wtor += 1

  ans = max(rtow, wtor)
  anses.append(ans)

print(min(anses))


### FIXED CODE ###

n = int(input())
c = input()

rtow = c.count('R')
wtor = 0

anses = []
for i in range(n + 1):
  anses.append(max(rtow, wtor))
  if i == n:
    break
  if c[i] == 'W':
    wtor += 1
  else:
    rtow -= 1

print(min(anses))
### BUGGY CODE ###

x, y, z, k = map(int,input().split())
alist = [int(i) for i in input().split()]
blist = [int(i) for i in input().split()]
clist = [int(i) for i in input().split()]


# print(x,y,z,k, alist, blist, clist)

#%%
# x,y,z,k,alist,blist,clist = 2, 2, 2, 8, [4, 6],[1, 5],[3, 8]


#%%
alist.sort()
blist.sort()
clist.sort()
alist = alist[::-1][:k]
blist = blist[::-1][:k]
clist = clist[::-1][:k]

#%%
import itertools




#%%
ans = []
for i in list(itertools.product(alist, blist, clist)):
    ans.append((sum(i)))

ans.sort()
#%%
for i in ans[::-1][:k]:
    print(i)

#%%


### FIXED CODE ###

# https://atcoder.jp/contests/abc123/tasks/abc123_d

def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

X, Y, Z, K = MAP()
A = LIST()
B = LIST()
C = LIST()

# A.sort(reverse=True); B.sort(reverse=True); C.sort(reverse=True)

E = []
for a in A:
    for b in B:
        E.append(a+b)
E.sort(reverse=True)

ans = []

for c in C[:K]:
    for e in E[:K]:
        ans.append(c+e)
ans.sort(reverse=True)

for i, a in enumerate(ans):
    if i < K:
        print(a)
    else:
        break
### BUGGY CODE ###

def main():
  import sys
  input = sys.stdin.readline

  X,Y,Z,K = map(int,input().split())
  A = list(map(int,input().split()))
  B = list(map(int,input().split()))
  C = list(map(int,input().split()))
  AB = [a+b for a in A for b in B]
  res = [c+ab for c in C for ab in AB]
  res.sort(reverse = True)
  print("\n".join(list(map(str,res[:K]))))

if __name__ == "__main__":
  main()


### FIXED CODE ###

def main():
  import sys
  input = sys.stdin.readline

  X,Y,Z,K = map(int,input().split())
  A = list(map(int,input().split()))
  B = list(map(int,input().split()))
  C = list(map(int,input().split()))
  A.sort(reverse = True)
  B.sort(reverse = True)
  C.sort(reverse = True)
  AB = [a+b for a in A for b in B]
  AB.sort(reverse = True)
  res = [c+ab for ab in AB[:min(K, len(AB))] for c in C]
  res.sort(reverse = True)
  print("\n".join(list(map(str,res[:K]))))

if __name__ == "__main__":
  main()
### BUGGY CODE ###

N,Q=map(int,input().split())
S=list(input())
count_list=[]

for i in range(Q):
    l,r=map(int,input().split())
    l,r=l-1,r-1 #リストのインデックスとの整合
    counter=0
    for j in range(l,r): 
        if S[j] =='A' and S[j+1]=='C':
            counter+=1
    count_list.append(counter)
for k in count_list:
    print(k)

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
### BUGGY CODE ###

import sys

N = int(input())

s = [None] * N
l, c, r = 0, N//2, N-1

while True:
    for i in (l, c, r):
        if s[i] == None:
            print(i, flush=True)
            s[i] = input()
        if s[i] == 'Vacant':
            sys.exit()
    if s[l] != s[c]:
        r = c
        c = (l + r) // 2
    else:
        l = c
        c = (l + r) // 2


### FIXED CODE ###

N = int(input())

s = [None] * N
l, c, r = 0, N//2, N-1

while True:
    for i in (l, c, r):
        if s[i] == None:
            print(i, flush=True)
            s[i] = input()
            if s[i] == 'Vacant':
                exit()
    if ((c-l)%2==0 and s[l]!=s[c]) or ((c-l)%2 and s[l]==s[c]):
        r = c
        c = (l + r) // 2
    else:
        l = c
        c = (l + r) // 2
### BUGGY CODE ###

# input
n = int(input())
edges = set(tuple(int(i) for i in input().split()) for _ in range(n-1))


from collections import deque


def diameter(tree):
    _, s = farest(tree, 1)
    diam, _ = farest(tree, s)
    return diam


def farest(tree, i):
    dp = [None for _ in range(n)]
    dp[i-1] = 0
    cand_q = deque()
    cand_q.append(i)

    while len(cand_q) > 0:
        u = cand_q.popleft()
        for edge in tree:
            if u in edge:
                v = edge[0] if u == edge[1] else edge[1]
                if dp[v-1] is None:
                    cand_q.append(v)
                    dp[v-1] = dp[u-1] + 1
    max_ = max(dp)
    i_max = dp.index(max_)
    return max_, i_max + 1


d = diameter(edges)


print('Second' if d % 3 == 1 else 'First')
    

# def farest_vtx(tree, i):
#     cand = deque(tree)
#     for edge in cand:
#         if i in edge:


### FIXED CODE ###

# input
n = int(input())
edges = set(tuple(int(i) for i in input().split()) for _ in range(n-1))


from collections import deque


def make_connection(tree):
    con = [[] for _ in range(n+1)]
    for edge in tree:
        con[edge[0]].append(edge[1])
        con[edge[1]].append(edge[0])
    return con


def diameter(tree):
    c = make_connection(tree)
    _, s = farest(tree, c, 1)
    diam, _ = farest(tree, c, s)
    return diam


def farest(tree, con, i):
    dp = [None for _ in range(n+1)]
    dp[i] = 0
    cand_q = deque()
    cand_q.append(i)

    while len(cand_q) > 0:
        u = cand_q.popleft()

        for v in con[u]:
            if dp[v] is None:
                cand_q.append(v)
                dp[v] = dp[u] + 1
    max_ = max(dp[1:])
    i_max = dp.index(max_)
    return max_, i_max


d = diameter(edges)


print('Second' if d % 3 == 1 else 'First')
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(W, H, P, Q):
    W += 1
    H += 1
    ans = 0
    for i, p in enumerate(P):
        ans += p

    for i, q in enumerate(Q):
        ans += q


    for i in range(1, H):
        for j in range(1, W):
            if P[j-1] < Q[i-1]:
                ans += P[j-1]
            else:
                ans += Q[i-1]

    return ans


def main():
    W, H = read_int_n()
    P = [read_int() for _ in range(W)]
    Q = [read_int() for _ in range(H)]
    print(slv(W, H, P, Q))


if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(W, H, P, Q):
    W += 1
    H += 1
    ans = sum(P) + sum(Q)

    P.sort()
    Q.sort()
    # print(P)
    for q in Q:
        i = bisect.bisect_left(P, q)
        # print(i, q)
        ans += q * (len(P)-i)
    for p in P:
        i = bisect.bisect_right(Q, p)
        # print(i, p)
        ans += p * (len(Q)-i)

    return ans


def main():
    W, H = read_int_n()
    P = [read_int() for _ in range(W)]
    Q = [read_int() for _ in range(H)]
    print(slv(W, H, P, Q))


if __name__ == '__main__':
    main()
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
c_num = set(a)
c_num = list(c_num)
c_cnt = [0]*(len(c_num))

for i in a:
    index = c_num.index(i)
    c_cnt[index] += 1

for i, x in enumerate(c_num):
    c_cnt[i] -= x

ans = 0

for i, x in zip(c_num, c_cnt):
    if x > 0:
        ans += x
    elif x < 0:
        ans += i + x

print(ans)

### FIXED CODE ###

def count(list):
    dict = {}
    for i in range(len(list)):
        dict[list[i]] = dict.get(list[i], 0) + 1
    return dict

n = int(input())
a = list(map(int,input().split()))
dic = count(a)
ans = 0

for i, x in dic.items():
    differ = x - i
    if differ>0:
        ans += differ
    elif differ<0:
        ans += x

print(ans)
### BUGGY CODE ###

X, Y = map(int, input().split())


def checkY(N, count, X):
    if count == X and N == 0:
        print("Yes")
        exit(0)
    elif count == X and N != 0:
        return False

    if checkY(N - 2, count + 1, X):
        return True

    if checkY(N - 4, count + 1, X):
        return True

    return False


if 2 * X <= Y and Y <= 4 * X:
    if checkY(Y, 0, X):
        print("Yes")
    else:
        print("No")
else:
    print("No")


### FIXED CODE ###

X, Y = map(int, input().split())

crane = (4 * X - Y) / 2
turtle = (Y - 2 * X) / 2


def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False


if is_integer_num(crane) and crane >= 0 and is_integer_num(turtle) and turtle >= 0:
    print("Yes")

else:
    print("No")
### BUGGY CODE ###

#!/usr/bin/env python3
#ABC75 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n,K = LI()
xy = [LI() for _ in range(n)]
ans = inf
for _ , uy in xy:
    for _ , dy in xy:
        if uy < dy:
            continue
        for rx , _ in xy:
            for lx , _ in xy:
                if rx < lx:
                    continue
                cnt = 0
                for x,y in xy:
                    if lx <= x <= rx and dy <= y <= uy:
                        cnt += 1
                if cnt >= K:
                    S = (uy - dy)*(rx - lx)
                    ans = min(ans,S)
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
#ABC75 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n,K = LI()
xy = []
X = []
Y = []
for _ in range(n):
    x,y = LI()
    xy.append([x,y])
    X.append(x)
    Y.append(y)
X.sort(reverse = True)
Y.sort(reverse = True)
ans = inf
for i in range(n):
    uy = Y[i]
    for j in range(i+1,n):
        dy = Y[j]
        for k in range(n):
            rx = X[k]
            for l in range(k+1,n):
                lx = X[l]
                cnt = 0
                for x,y in xy:
                    if lx <= x <= rx and dy <= y <= uy:
                        cnt += 1
                if cnt >= K:
                    S = (uy - dy)*(rx - lx)
                    ans = min(ans,S)
print(ans)
### BUGGY CODE ###

s = input()
k = int(input())

subs = set()

for i in range(len(s)):
  for j in range(i+1, len(s)+1):
    subs.add(s[i:j])
subs = list(subs) 
subs.sort()
print(subs[k-1])

### FIXED CODE ###

s = input()
k = int(input())

subs = set()

for i in range(len(s)):
  for j in range(i+1, min(5+i+1, len(s)+1)):

    subs.add(s[i:j])
subs = list(subs) 
subs.sort()
print(subs[k-1])
### BUGGY CODE ###

# F - Strivore
import sys
sys.setrecursionlimit(10**8)
INF = 10**9+7
K = int(input())
S = input()
l = len(S)

def power(x,n):
    global INF
    if n==0:
        return 1
    elif n%2==0:
        return (power(x,n//2)**2)%INF
    else:
        return (x*(power(x,n//2)**2))%INF
    
kakeru = 25
waru = power(26,INF-2)

tmp = power(26,K)
ans = tmp
for i in range(1,K+1):
    tmp = (tmp*kakeru*waru)%INF
    tmp = (tmp*(l-1+i)*power(i,INF-2))%INF
    ans = (ans+tmp)%INF
print(ans)

### FIXED CODE ###

# F - Strivore
import sys
MOD = 10**9+7
K = int(input())
S = input()
l = len(S)
ans = 0

tmp = pow(26,K,MOD)
ans = tmp
waru = pow(26,-1,MOD)

for i in range(1,K+1):
    tmp = (tmp*25*waru)%MOD
    tmp = (tmp*(l-1+i)*pow(i,-1,MOD))%MOD
    ans = (ans+tmp)%MOD

print(ans)
### BUGGY CODE ###

N = int(input())
lsa = list(map(int,input().split()))
lsb = []
for i in range(N):
    lsb.append(lsa[i])
    lsb.reverse()
lsans = [str(i) for i in lsb]
print(' '.join(lsans))

### FIXED CODE ###

import collections
N = int(input())
lsa = list(map(str,input().split()))
lsb = collections.deque()
if N%2 == 0:
    for i in range(N):    
        if i % 2 == 0:
            lsb.append(lsa[i])
        else:
            lsb.appendleft(lsa[i])
if N%2 == 1:
    for i in range(N):
        if i % 2 == 1:
            lsb.append(lsa[i])
        else:
            lsb.appendleft(lsa[i])

print(' '.join(lsb))
### BUGGY CODE ###

from itertools import accumulate
n=int(input())
l=[0]+list(accumulate(list(map(int,input().split()))))
ans=float("INf")

for center in range(2,n-1):
    lnow=1
    laim=l[center]//2
    while lnow+1<center and l[lnow+1]<laim:lnow+=1
    rnow=center+1
    raim=(l[-1]-l[center])//2
    while rnow+1<n and l[rnow+1]-l[center]<raim:rnow+=1
    for i,j in ((0,0),(1,0),(1,1),(0,1)):
        if lnow+i<center and rnow+j<n:
            a,b,c,d=sorted([l[lnow+i],l[center]-l[lnow+i],l[rnow+j]-l[center],l[-1]-l[rnow+j]])
            ans=min(ans,d-a)
print(ans)

### FIXED CODE ###

from itertools import accumulate
n=int(input())
l=[0]+list(accumulate(list(map(int,input().split()))))
ans=float("INf")
lnow=1
rnow=3
for center in range(2,n-1):

    laim=l[center]//2
    while lnow+1<center and l[lnow+1]<laim:lnow+=1
    if rnow<=center:rnow=center+1
    raim=(l[-1]-l[center])//2
    while rnow+1<n and l[rnow+1]-l[center]<raim:rnow+=1
    for i,j in ((0,0),(1,0),(1,1),(0,1)):
        if lnow+i<center and rnow+j<n:
            a=(l[lnow+i],l[center]-l[lnow+i],l[rnow+j]-l[center],l[-1]-l[rnow+j])
            ans=min(ans,max(a)-min(a))
print(ans)