Harryxun/stf_run huggingface dataset:
from collections import defaultdict
d=defaultdict(int)
dw=defaultdict(int)
n,m=map(int,input().split())
l=[]
for i in range(n):
  l.append(list(input()))
lb=[[0 for i in range(m)]for j in range(n)]
move=[[1,0],[-1,0],[0,1],[0,-1]]
def dfs(n1,n2,w,n3):
  if lb[n1][n2]!=0:
    return None
  else:
    lb[n1][n2]=n3
    if w==".":
      w1="#"
    else:
      w1="."
    for j in move:
      dx=j[0]
      dy=j[1]
      x=dx+n1
      y=dy+n2
      if 0>x or x>n-1 or y<0 or y>n-1:
        pass
      else:
        if w1!=l[x][y]:
          pass
        else:
          dfs(x,y,w1,n3)
    return None
dfs(0,0,l[0][0],1)
num=1
for i in range(n):
  for j in range(m):
    dfs(i,j,l[i][j],num)
    num+=1
for i in range(n):
  for j in range(m):
    d[lb[i][j]]+=1
    if l[i][j]=="#":
      dw[lb[i][j]]+=1
ans=0
for i in d:
  ans+=dw[i]*(d[i]-dw[i])
print(ans)

### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(1000000)
d=defaultdict(int)
dw=defaultdict(int)
n,m=map(int,input().split())
l=[]
for i in range(n):
  l.append(list(input()))
lb=[[0 for i in range(m)]for j in range(n)]
move=[[1,0],[-1,0],[0,1],[0,-1]]
def dfs(n1,n2,w,n3):
  if lb[n1][n2]!=0:
    return None
  else:
    lb[n1][n2]=n3
    if w==".":
      w1="#"
    else:
      w1="."
    for j in move:
      dx=j[0]
      dy=j[1]
      x=dx+n1
      y=dy+n2
      if 0>x or x>n-1 or y<0 or y>m-1:
        pass
      else:
        if w1!=l[x][y]:
          pass
        else:
          dfs(x,y,w1,n3)
    return None
dfs(0,0,l[0][0],1)
num=1
for i in range(n):
  for j in range(m):
    dfs(i,j,l[i][j],num)
    num+=1
for i in range(n):
  for j in range(m):
    d[lb[i][j]]+=1
    if l[i][j]=="#":
      dw[lb[i][j]]+=1
ans=0
for i in d:
  ans+=dw[i]*(d[i]-dw[i])
print(ans)
n=int(input())

x=[[int(i) for i in input().split()] for i in range(n)]
#print(x)

def hight(a,b,x,y,z):
  h=z+abs(x-a)+abs(y-b)
  return h

ans=0

for k in range(101):
  for l in range(101):
    flag=0
    for i in range(1,n):
      if hight(k,l,x[-1][0],x[-1][1],x[-1][2])==hight(k,l,x[i][0],x[i][1],x[i][2]):
        flag+=1 
    if flag==n-1:
      ans1=k
      ans2=l
      ans3=hight(k,l,x[-1][0],x[-1][1],x[-1][2])

print(ans1,ans2,ans3)

### FIXED CODE ###

n=int(input())

x=[[int(i) for i in input().split()] for i in range(n)]
#print(x)
cnt=0
for m in range(n):
  if x[m][2]>0:
    cnt+=1
    ii=m
    
#print(ii,cnt)

def hight(a,b,x,y,z):
  h=z+abs(x-a)+abs(y-b)
  return h

for i in range(101):
  for j in range(101):
    flag=0
    for k in range(n):
      if x[k][2]>0:
        if hight(i,j,x[ii][0],x[ii][1],x[ii][2])==hight(i,j,x[k][0],x[k][1],x[k][2]):
          flag+=1
      else:
        if hight(i,j,x[ii][0],x[ii][1],x[ii][2]) > hight(i,j,x[k][0],x[k][1],x[k][2]):
          flag=0
     
    if flag==cnt:
      ans1=i
      ans2=j
      ans3=hight(i,j,x[ii][0],x[ii][1],x[ii][2])
      
print(ans1,ans2,ans3)
#print(flag)
a,b = map(int(input().split()))

for i in range(1300):
    if i == a*12.5 and b*10:
        print(i)
        exit()
print(-1)

### FIXED CODE ###

a,b = map(int,input().split())
import math
c = []
d =[]
for i in range(1300):
    if math.floor(i*0.08)==a and math.floor(i*0.1)==b:
        c.append(i)
    else:
        d.append(i)
if len(c) ==0 :
    print(-1)
else:
    print(min(c))
def main():
    H, W = map(int, input().split())
    A = []
    B = []
    M = 80 * H * W
    for _ in range(H):
        a = tuple(map(int, input().split()))
        A.append(a)
    for _ in range(H):
        b = tuple(map(int, input().split()))
        B.append(b)
    l = [[[0] * (M+1) for _ in range(W)] for _ in range(H)]
    for i in range(H):
        for j in range(W):
            if i == 0 and j == 0:
                t = abs(A[0][0] - B[0][0])
                l[i][j][t] = 1
            else:
                t = abs(A[i][j] - B[i][j])
                for k in range(M+1):
                    if i > 0 and l[i-1][j][k] == 1:
                        if k + t <= M:
                            l[i][j][k+t] = 1
                        if k - t >= 0:
                            l[i][j][k-t] = 1
                        if t - k >= 0:
                            l[i][j][t-k] = 1
                    if j > 0 and l[i][j-1][k] == 1:
                        if k + t <= M:
                            l[i][j][k+t] = 1
                        if k - t >= 0:
                            l[i][j][k-t] = 1
                        if t - k >= 0:
                            l[i][j][t-k] = 1
    for k in range(M):
        if l[-1][-1][k] == 1:
            return k
print(main())



### FIXED CODE ###

import sys
def main():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    A = []
    B = []
    M = 80 * (H + W)
    for _ in range(H):
        a = tuple(map(int, input().split()))
        A.append(a)
    for _ in range(H):
        b = tuple(map(int, input().split()))
        B.append(b)
    AB = [[0] * W for _ in range(H)]
    for i in range(H):
        for j in range(W):
            AB[i][j] = abs(A[i][j] - B[i][j])
    l = [set([]) for _ in range(W)]
    lt = [set([]) for _ in range(W)]
    for i in range(H):
        for j in range(W):
            if i == 0 and j == 0:
                lt[j].add(AB[0][0])
            else:
                t = AB[i][j]
                if i > 0:
                    for k in l[j]:
                        lt[j].add(k+t)
                        lt[j].add(abs(k-t))
                if j > 0:
                    for k in lt[j-1]:
                        lt[j].add(k+t)
                        lt[j].add(abs(k-t))
        l = lt
        lt = [set([]) for _ in range(W)]
    return min(l[-1])
print(main())
N, A, B, C, D = map(int, input().split())
 
S = input()
 
S = S + '#'
 
def continuous_rock_search(S, A, B, C, D):
    begin = min(A, B)
    target = max(C, D)
    for i in range(begin - 1, target - 1):
        if S[i] == '#' and S[i+1] == '#':
            return True
    return False
  
def validation_funuke_move(S, B, D):
    '''
    ふぬけ君が両隣に岩がなくなるまで移動したとき、Dより向こうにはイカないことを確認する。
    True/False and ふぬけの移動後の位置
    '''
    funuke_position = B
    while (B <= D):
        if (S[B-2] == '#' or S[B] == '#'):
            if S[B] == '.' :
                B = B + 1
            else:
                B = B + 2
        elif (S[B-2] == '.' and S[B] == '.'):
            return True, B
    
    return False, -1
  
def KenKenRace(S, A, B, C, D):
    if continuous_rock_search(S,A, B C, D):
        return False
    
    if C < D:
        return True
    
    if D < C:
        valid , _ = validation_funuke_move(S, B, D)
        if valid:
            return True
        else:
            return False
          
if KenKenRace(S, A, B, C, D):
    print('Yes')
else:
    print('No')


### FIXED CODE ###

N, A, B, C, D = map(int, input().split())
 
S = input()
 
S = S + '#'
 
def continuous_rock_search(S, A, B, C, D):
    begin = min(A, B)
    target = max(C, D)
    for i in range(begin, target - 1):
        if S[i] == '#' and S[i+1] == '#':
            return True
    return False
  
def validation_funuke_move(S, B, D):
    '''
    ふぬけ君が両隣に岩がなくなるまで移動したとき、Dより向こうにはイカないことを確認する。
    True/False and ふぬけの移動後の位置
    '''
    funuke_position = B
    while (B <= D):
        if (S[B-2] == '#' or S[B] == '#'):
            if S[B] == '.' :
                B = B + 1
            else:
                B = B + 2
        elif (S[B-2] == '.' and S[B] == '.'):
            return True, B
    
    return False, -1
  
def KenKenRace(S, A, B, C, D):
    if continuous_rock_search(S, A, B, C, D):
        return False
    
    if C < D:
        return True
    
    if D < C:
        valid , _ = validation_funuke_move(S, B, D)
        if valid:
            return True
        else:
            return False
          
if KenKenRace(S, A, B, C, D):
    print('Yes')
else:
    print('No')
b=input()
if b=A:
  print("T")
elif b=T:
  print("A")
elif b=C:
  print("G")
else:
  print("C")

### FIXED CODE ###

b=input()
if b=="A":
  print("T")
elif b=="T":
  print("A")
elif b=="C":
  print("G")
else:
  print("C")
import sys
input=sys.stdin.readline

ans=0
N,M=map(int,input().split())
Ar=[[] for _ in range(M)]
for _ in range(N):
      A,B=map(int,input().split())
      Ar[A-1].append(B)
An=[]
for i in range(M):
      An += Ar[i]
      if len(An)>0:
          ans+=An.pop(An.index(max(An))) 
print(ans)

### FIXED CODE ###

import heapq
N , M = map(int , input().split())
jobs = [list(map(int , input().split())) for _ in range(N)]
jobs.sort()

q = []
index = 0
ans = 0
for limit in range(1 , M + 1):
    while index < N:
        time =jobs[index][0]
        reward = jobs[index][1]
        if limit >= time:
            heapq.heappush(q , -reward)
            index += 1
        else:
            break
    #print(q)
    if len(q) != 0:
        tmp = heapq.heappop(q)
        ans -= tmp

print(ans)
n = [int(x) for ix in input()]
l=len(n)-1
for i in range(2**l):
    op=["-"]*l
    for j in range(l):
        if ((i>>j)&1):
            op[l-1-j]="+"
    formula=""
    for p,q in zip(n,op + [""]):
        formula+=(p+q)
    if eval(formula)==7:
        print(formula + "=7" )
        break

### FIXED CODE ###

n = [x for x in input()]
l=len(n)-1
for i in range(2**l):
    op=["-"]*l
    for j in range(l):
        if ((i>>j)&1):
            op[l-1-j]="+"
    formula=""
    for p,q in zip(n,op + [""]):
        formula+=(p+q)
    if eval(formula)==7:
        print(formula + "=7" )
        break
'''
　 ∧_,,∧    究極奥義「WAがACになーれ！！」
　（`・ω・)つ━☆・*。
　⊂　　 ノ 　　　・゜+.
　 し’´Ｊ　　*・ 
'''
import sys
input = sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
ans=1
cnt=0
i=0
while i<n-1 and cnt<2:
    if a[i]==a[i+1]:
        ans*=a[i]
        i+=2
        cnt+=1
    else:
        i+=1
if cnt==2:
    print(ans)
else:
    print(0)


### FIXED CODE ###

n = int(input())
s = input() + "@"
t = input() + "@"
mod = 10 ** 9 + 7

# 情報を1次元にして処理しやすくするぜ
# 縦で一致 True 横で一致 False
b = []
for i in range(n):
    if s[i] == s[i + 1]:
        continue
    b.append(s[i] == t[i])

# 処理するぜ
if b[0]:
    ans = 3
else:
    ans = 6

for i in range(1, len(b)):
    if b[i]:
        if b[i - 1]:
            ans *= 2
    else:
        if b[i - 1]:
            ans *= 2
        else:
            ans *= 3

print(ans % mod)
N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]

step = [0] * (N+1)
if 1 in A:
  step[1] = 0
else:
  step[1] = 1
if 2 in A:
  step[2] = 0
else:
  step[2] = step[1] + 1

for i in range(3, N+1):
  if i in A:
    step[i] = 0
  else:
    step[i] = step[i-1] + step[i-2]
print(step[N]%(10**9+7))
  
  


### FIXED CODE ###

N, M = map(int, input().split())
A = [True] * (N+1)
for _ in range(M):
  idx = int(input())
  A[idx] = False

step = [0] * (N+1)
step[0] = 1
for i in range(1, N+1):
  if A[i]:
    step[i] = step[i-1] + step[i-2]
  else:
    step[i] = 0
print(step[N]%(10**9+7))
s, w = map(int, input().split())
if w >= s:
  	print("unsafe")
else:
  	print("safe)

### FIXED CODE ###

sheep, wolves = map(int, input().split())
print("unsafe" if wolves >= sheep else "safe")
import collections 
N = int(input())
dic = {"a":1,"b":2,"c":3,"d":4,"e":5,"f":6,"g":7,"h":8,"i":9,"j":10,"k":11,"l":12,"m":13,"n":14,"o":15,"p":16,"q":17,"r":18,"s":19,"t":20,"u":21,"v":22,"w":23,"x":24,"y":25,"z":26}

ans = []
for i in range(N):
    si = input()
    a = [0]*26
    s = ""
    for j in range(10):
        a[dic[si[j]]] += 1
    for k in range(26):
        s = s + "a"
        s = s + str(a[k])
    ans.append(s)
c = collections.Counter(ans)
b = 0
for v in c.values():
    if v > 1:
        b += v*(v-1)//2
    else:
        pass
print(b)
    

### FIXED CODE ###

from collections import Counter
N = int(input())
dic = {"a":1,"b":2,"c":3,"d":4,"e":5,"f":6,"g":7,"h":8,"i":9,"j":10,"k":11,"l":12,"m":13,"n":14,"o":15,"p":16,"q":17,"r":18,"s":19,"t":20,"u":21,"v":22,"w":23,"x":24,"y":25,"z":26}

ans = []
for i in range(N):
    si = input()
    a = [0]*26
    s = ""
    for j in range(10):
        a[dic[si[j]]-1] += 1
    for k in range(26):
        s = s + "a"
        s = s + str(a[k])
    ans.append(s)
c = Counter(ans)
b = 0
for v in c.values():
    if v > 1:
        b += v*(v-1)//2
    else:
        pass
print(b)
n = int(input())
xyh = [tuple(map(int, input().split())) for i in range(n)]
print(xyh)

for cx in range(101):
    for cy in range(101):
        height = set(hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in xyh if hi > 0)
        print(height)
        if len(height) == 1:
            H = max(height)
            if all(set(hi=max(H - abs(xi-cx) - abs(yi-cy), 0)) for xi, yi, hi in xyh if hi == 0):
                print(cx, cy, H)
                exit()

### FIXED CODE ###

n = int(input())
xyh = [tuple(map(int, input().split())) for i in range(n)]

for cx in range(101):
    for cy in range(101):
        height = set(hi + abs(xi-cx) + abs(yi-cy) for xi, yi, hi in xyh if hi > 0)
        if len(height) == 1:
            H = max(height)
            if all(set(hi==max(H - abs(xi-cx) - abs(yi-cy), 0) for xi, yi, hi in xyh if hi == 0)):
                print(cx, cy, H)
                exit()
import sys
import math
from itertools import accumulate as acc

input=sys.stdin.readline

N=int(input())
a=list(map(int,input().split()))
b=[abs(a[i]) for i in range(N)]
l=b.index(max(b))

if a[l]==0: print(0),sys.exit()
elif a[l]>0:
	print(N*2)
	for i in range(2):
		print(l+1,1)
	for i in range(1,N):
		for j in range(2):
			print(i,i+1)

else:
	print(N*2)
	for i in range(2):
		print(l+1,N)
	for i in range(N,1,-1):
		for j in range(2):
			print(i,i-1)

### FIXED CODE ###

s=input()
print(sum( int(s[i]) for i in range(3) ))
import fractions
K = int(input())
A = [i for i in range(1, K)]
B = [i for i in range(1, K)]
C = [i for i in range(1, K)]

cnt = 0
for a in A:
  for b in B:
    for c in C:
      N = [a,b,c]
      ans = N[0]
      for i in range(1, 3):
        ans = fractions.gcd(ans, a[i])
      cnt += ans
print(cnt)

### FIXED CODE ###

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
  
K = int(input())
A = B = C = [i for i in range(1, K+1)]

L = [gcd(a,b) for a in A for b in B]

cnt = sum([gcd(l,c) for l in L for c in C])   
print(cnt)
n=int(input())
a= list(map(int,input().split()))

#for i in a:
#i=0
b=[0]*(max(a)+2)
r=0
#while i<=n:
for i in a:
    b[i]+=1
    b[i+1]+=1
    b[i+2]+=1
print(max(b)-1)


    A=a.count(a[i]+1)
    M=a.count(a[i])
    C=a.count(a[i]-1)

    b[i]=A+M+C
i=0
def dfs(i,j):

    
    max(dfs(i+1,j),dfs(i,j+1))

print(max(b))


### FIXED CODE ###

n=int(input())
a= list(map(int,input().split()))

#for i in a:
#i=0
b=[0]*(10**5+10)
r=0
#while i<=n:
for i in a:
    b[i]+=1
    b[i+1]+=1
    b[i+2]+=1

print(max(b))
A,V = map(int,input().rstrip().split(" "))
B,W = map(int,input().rstrip().split(" "))
T = int(input())
if(V <= W):
    print("NO")
else:
    if(abs(A - B) <= (V - W) * T):
        print("YES")
    else:
        Print("NO")

### FIXED CODE ###

A,V = map(int,input().rstrip().split(" "))
B,W = map(int,input().rstrip().split(" "))
T = int(input())
if(abs(A - B) <= (V - W) * T):
    print("YES")
else:
    print("NO")
# -*- coding: utf-8 -*-
# if x < y:
#     z = x
# elif True:
#     z = y
# else:
#     z = 100
import sys,os,math
from collections import Counter, defaultdict
import bisect
from sys import stdin, stdout
from itertools import repeat

sys.stdin = open('input')
# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())

def main():
    n, m = map(int, raw_input().split())
    bf, af = [10000000 for i in range(1<<n)], [10000000 for i in range(1<<n)]
    bf[0] = 0
    for i in range(m):
        a, b = map(int, raw_input().split())
        ad = 0
        for st in map(int, raw_input().split()):
            ad |= 1<<(st-1)

        for st in range(1<<n):
            af[st|ad] = min(bf[st|ad], bf[st]+a, af[st|ad])
        # print af
        bf, af = af, bf
    if bf[(1<<n)-1] == 10000000:
        print -1
    else:
        print bf[(1<<n)-1]



main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
# if x < y:
#     z = x
# elif True:
#     z = y
# else:
#     z = 100
import sys,os,math
from collections import Counter, defaultdict
import bisect
from sys import stdin, stdout
from itertools import repeat


# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())

def main():
    n, m = map(int, raw_input().split())
    bf, af = [10000000 for i in range(1<<n)], [10000000 for i in range(1<<n)]
    bf[0] = 0
    for i in range(m):
        a, b = map(int, raw_input().split())
        ad = 0
        for st in map(int, raw_input().split()):
            ad |= 1<<(st-1)
        for st in range(1<<n):
            af[st|ad] = min(bf[st|ad], bf[st]+a, af[st|ad])
        for st in range(1<<n):
            af[st] = min(af[st], bf[st])
        bf, af = af, bf
    if bf[(1<<n)-1] == 10000000:
        print -1
    else:
        print bf[(1<<n)-1]



main()
a,b,c = map(int, input().split())
if a*b <= c:
    print(a*b)
    else:
        print(c)

### FIXED CODE ###

a,b,c = map(int, input().split())
if a*b <= c:
    print(a*b)
else:
    print(c)
s = input()
x,y = map(int,input().split())
k = 0
data = [[],[]]
f = 0
p = 1
for s_ in s:
    if p==1 and s_=='F':
        x -= 1
        continue
    p = 0
    if s_ == 'T':
        if f:
            data[k].append(f)
        k = (k+1)%2
        f = 0
    else:
        f += 1
if f:
    data[k].append(f)

nx = sum(data[0])
ny = sum(data[1])

dpx = [[0]*max((nx+2)*2,(x+2)*2) for _ in range(len(data[0])+1)]
dpy = [[0]*max((ny+2)*2,(y+2)*2) for _ in range(len(data[1])+1)]
x_zero = max(nx+1,x+1)
y_zero = max(ny+1,y+1)
dpx[0][x_zero] = 1
dpy[0][y_zero] = 1

for i in range(len(data[0])):
    for j in range(len(dpx[i])):
        if dpx[i][j]==1:
            dpx[i+1][j+data[0][i]] = 1
            dpx[i+1][j-data[0][i]] = 1

for i in range(len(data[1])):
    for j in range(len(dpy[i])):
        if dpy[i][j]==1:
            dpy[i+1][j+data[1][i]] = 1
            dpy[i+1][j-data[1][i]] = 1
if dpx[-1][x_zero+x]==1 and dpy[-1][y_zero+y]==1:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

now=0
idx=-1
data=[[],[]]
cnt=0
for s in input():
    if s=='F':
        cnt+=1
    elif s=='T':
        if idx==-1:
            now+=cnt
            cnt=0
            idx=1
        elif idx==0:
            data[0].append(cnt)
            cnt=0
            idx=1
        elif idx==1:
            data[1].append(cnt)
            cnt=0
            idx=0
if idx==-1:
    now+=cnt
else:
    data[idx].append(cnt)
def solve(target,move):
    dp={0,}
    for m in move:
        dpc=dp.copy()
        dp=set()
        for k in dpc:
            dp|={k-m,k+m}
    if target in dp:
        return True
    return False
x,y=map(int,input().split())
x-=now
if solve(x,data[0]) and solve(y,data[1]):
    print('Yes')
else:
    print('No')
import sys

def isCLKWISE(ph):
    if (ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0 : return False
    else : return True
     
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            if isCLKWISE(phU) : break
            else :
                del phU[-2]
                if len(phU) == 2 : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            if isCLKWISE(phL) : break
            else :
                del phL[-2]
                if len(phL) == 2 : break
    ph = phU + phL[1:-1]
    return ph

_input = sys.stdin.readlines()
n = int(_input[0])
P = map(lambda x: x.split(), _input[1:])
     
Q = ConvexHullScan(P)
Q.reverse()
print(len(Q))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(Q)])[2]
R = Q[idx:] + Q[:idx]
for r in R:
    print(r[0],r[1])

### FIXED CODE ###

def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P):
    P = sorted(P)
    phU = [P[0],P[1]]
    for p in P[2:]:
        phU.append(p)
        while(True):
            try :
                if isCLKWISE(phU) : break
                else : del phU[-2]
            except IndexError : break
    phL = [P[-1],P[-2]]
    for p in P[-3::-1]:
        phL.append(p)
        while(True):
            try :
                if isCLKWISE(phL) : break
                else : del phL[-2]
            except IndexError : break
    ph = phU + phL[1:-1]
    return ph
  
P = [[int(x) for x in input().split()] for _ in range(int(input()))]
P = ConvexHullScan(P)
P.reverse()
print(len(P))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(P)])[2]
for p in P[idx:] + P[:idx] : print(p[0],p[1])
mod = 10**9 + 7  # 998244353 # 変える


def table():
    k = 2 * 10**5 + 5  # 変える
    fac = [1] * k
    finv = [1] * k
    inv = [0] * k
    inv[1] = 1
    for i in range(2, k):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod
    return fac, finv


fac, finv = table()


def comb(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


k = int(input())
s = input()
n = len(s) - 1
ans = 1
for i in range(k + 1):
    x = pow(26, k - i, mod) * pow(25, i, mod) % mod
    ans += (comb(n + i, i) * x)
    ans %= mod
print((ans - 1) % mod)

### FIXED CODE ###

mod = 10**9 + 7  # 998244353 # 変える


def table():
    k = 2 * 10**6 + 5  # 変える
    fac = [1] * k
    finv = [1] * k
    inv = [0] * k
    inv[1] = 1
    for i in range(2, k):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod
    return fac, finv


fac, finv = table()


def comb(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


k = int(input())
s = input()
n = len(s) - 1
ans = 1
for i in range(k + 1):
    x = pow(26, k - i, mod) * pow(25, i, mod) % mod
    ans += (comb(n + i, i) * x)
    ans %= mod
print((ans - 1) % mod)
ap,bp = 0
n = int(input())
for i in range(n):
    a,b = input().split()
    if a>b:
        ap+=3
    elif a==b:
        bp+=3
    else:
        bp+=3
    print(ap,bp)

### FIXED CODE ###

ap,bp = 0,0
n = int(input())
for i in range(n):
    a,b = input().split()
    if a>b:
        ap+=3
    elif a==b:
        ap+=1
        bp+=1
    else:
        bp+=3
print(ap,bp)
a=int(input())
p=int(input())
c=a*3
b=(c+p)/2
print(b)

### FIXED CODE ###

a,p=map(int,input().split())
c=a*3
b=(c+p)//2
print(b)
s = input()
count = 0
flag = True
while flag == True:
    flag = False
    for i in range(len(s)-1):
        if s[i] != s[i+1]:
            s = s[0:i]+s[i+2:]
            count += 2
            flag = True

print(count)

### FIXED CODE ###

s = input()
print(2*min(s.count('0'), s.count('1')))
x=int(input())
if x<1200:
      print(ABC)
else:
      print(ARC)


### FIXED CODE ###

x=int(input())
if x < 1200:
      print("ABC")
else:
      print("ARC")
# -*- coding: utf-8 -*-
N=input()
#値を入力
s=str(N)
s1=s[-1]
s2=s[-2]
s3=s[-3]
if s1==7:
  print('Yes')
  elif s2==7:
    print('Yes')
    elif s3==7:
      print('Yes')
      else:
        print('No')
      

### FIXED CODE ###

N=input()
s=str(N)
s1=s[-1]
s2=s[-2]
s3=s[-3]
if s1 == '7':
    print('Yes')
elif s2 == '7':
    print('Yes')
elif s3=='7':
    print('Yes')
else:
    print('No')
a1,a2,a3=map(intinput().split())
if a1+a2+a3>=22:
  print("bust")
else:
  print("win")

### FIXED CODE ###

a1,a2,a3=map(int,input().split())
if a1+a2+a3>=22:
  print("bust")
else:
  print("win")
a, b = map(int, intput().split())
print(max(a + b, a - b, a * b))

### FIXED CODE ###

a, b = map(int, input().split())
print(max(a + b, a - b, a * b))
import numpy as np
N = int(input())
A = np.array(list(map(int,input().split())))
mod = 10**9+7
lcm = np.lcm.reduce(A)
for i in A:
    ans += (lcm//i)%mod
print(ans%mod)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
import fractions
mod = 10**9+7
lcm = A[0]
for i in range(1,N):
    lcm = lcm*A[i]//fractions.gcd(lcm,A[i])
ans = 0
for i in range(N):
    ans += lcm*pow(A[i],mod-2,mod)
print(ans%mod)