Harryxun/stf_run huggingface dataset:
import math


def c_cnt(n, r):
    return math.factorial(n) // (math.factorial(n - r) * (math.factorial(r)))


N, K = map(int, input().split())
red = N - K
div = 1
for i in range(1,K+1):
    place = c_cnt(red+1, i)
    if 1 < i < K:
        div = c_cnt(K-1, i-1)
    else:
        div = 1
    print(place * div % (10**9+7))

### FIXED CODE ###

import math


def c_cnt(n, r):
    if n - r < 0:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * (math.factorial(r)))


N, K = map(int, input().split())
red = N - K
div = 1
for i in range(1,K+1):
    place = c_cnt(red+1, i)
    if 1 < i < K:
        div = c_cnt(K-1, i-1)
    else:
        div = 1
    print(place * div % (10**9+7))
def solve(stns, idx, mem):

    if idx >= len(stns) -1:
        return 0

    if idx in mem: 
        return mem[idx]

    if idx == len(stns) - 2: 
        # can take only one step
        # print(idx)  
        # final_step = solve(stns, idx + 1, mem) + abs(stns[idx] - stns[idx+1])
        final_step = abs(stns[idx] - stns[idx+1])
        mem[idx] = final_step
        return final_step
    else: 
        # step: i + 11
        step1 = solve(stns, idx + 1, mem) + abs(stns[idx] - stns[idx+1])
        # step: i + 2
        step2 = solve(stns, idx + 2, mem) + abs(stns[idx] - stns[idx+2])

        min_cost = min(step1, step2)
        mem[idx] = min_cost 

        return min_cost



def take_input():
    n = input()
    stns = [int(x) for x in input().split(' ')]
    mem = {}
    res = solve(stns, 0, mem)
    print(res)

take_input()

### FIXED CODE ###

import sys
def solve(stns, idx, mem):

    if idx >= len(stns) -1:
        return 0

    if idx in mem: 
        return mem[idx]

    if idx == len(stns) - 2: 
        # can take only one step
        # print(idx)  
        # final_step = solve(stns, idx + 1, mem) + abs(stns[idx] - stns[idx+1])
        final_step = abs(stns[idx] - stns[idx+1])
        mem[idx] = final_step
        return final_step
    else: 
        # step: i + 11
        step1 = solve(stns, idx + 1, mem) + abs(stns[idx] - stns[idx+1])
        # step: i + 2
        step2 = solve(stns, idx + 2, mem) + abs(stns[idx] - stns[idx+2])

        min_cost = min(step1, step2)
        mem[idx] = min_cost 

        return min_cost



def take_input():
    # n = input()
    # stns = [int(x) for x in input().split(' ')]



    reader = (s.rstrip() for s in sys.stdin)
    input = reader.__next__
    sys.setrecursionlimit(1000000)
    # do magic here
    n = int(input())
    stns = [int(x) for x in input().split()]
    mem = {}
    res = solve(stns, 0, mem)
    print(res)

take_input()
s=list(input())
if s[0]!='A':
  print("WA")
elseif s[2:len(s)-1].count("C")!=1:
  print('WA')
else:
  s.remove('A')
  s.remove('C')
  ns=str(s)
  if ns.islower():
    print("AC")
  else:
    print("WA")
  

### FIXED CODE ###

s=list(input())
if s[0]!='A':
  print("WA")
elif s[2:len(s)-1].count("C")!=1:
  print('WA')
else:
  s.remove('A')
  s.remove('C')
  ns=str(s)
  if ns.islower():
    print("AC")
  else:
    print("WA")
n=int(input())
r=math.ceil(Fraction(360,n))
print(r)

### FIXED CODE ###

import math
n=int(input())
if 360%n==0:
    print(360//n)
else:
    r=360*n//math.gcd(360,n)
    r//=n
    print(r)
int(input(X))

if X >= 30:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

X = int(input())

if X >= 30:
  print("Yes")
else:
  print("No")
while True:
    a,b = map(int,input().split())
    op = map(str,input().split())
    if op == "+":
        print (a + b)
    elif op == "-":
        print (a - b)
    elif op == "*":
        print (a * b)
    elif op == "/":
        print (a / b)
    elif op == "?":
        break
    else:
        break

### FIXED CODE ###

while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op == '+':
        print (a + b)
    elif op == '-':
        print (a - b)
    elif op == '*':
        print (a * b)
    elif op == '/':
        print (a // b)
    else:
        break
a,b,k=map(int,input().split())

aa =[]
bb=[]
cc=[]

for i in range(1,a):
    if a % i == 0:
        aa.append(i)

for i in range(1,b):
    if a % i == 0:
        bb.append(i)

if a==1:
    aa.append(1)

if b==1:
    bb.append(1)

cc=sorted(list(set(aa) & set(bb)))
print(cc[k-1])

### FIXED CODE ###

a,b,k=map(int,input().split())

c=[]

for i in range(1,max(a,b)+1):
    if a % i == 0 and b % i == 0:
        c.append(i)
c.sort(reverse=True)

print(c[k-1])
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
a=n1()

ans=0
for i in range(n):
    h=a[i]
    B=list(range(-i,-i+n))
    C=[0]*n
    for j in n:
        C[j]=abs(B[j])-A[j]-h
    ans+=C.count(0)
print(ans//2)

### FIXED CODE ###

def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

from collections import defaultdict
n=n0()
a=[0]
a.extend(n1())

m1=[i+a[i] for i in range(n+1)]
m2=[j-a[j] for j in range(n+1)]

d1=defaultdict(list)
d2=defaultdict(list)
for i in range(1,n+1):
    d1[m1[i]].append(i)
    d2[m2[i]].append(i)

ans=0
for i in d1:
    ans+=len(d1[i])*len(d2[i])
            
print(ans)
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def solve():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ruia, ruib = [0], [0]
    for i in range(n): ruia.append(a[i]+ruia[i])
    for i in range(m): ruib.append(b[i]+ruib[i])
    ans = 0
    j = m
    for i in range(n+1):
        if ruia[i] > k:
            break
        while(k > ruia[i]+ruib[j]):
            j -= 1
        ans = max(ans, i+j)
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

### FIXED CODE ###

import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def solve():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    ruia, ruib = [0], [0]
    for i in range(n): ruia.append(a[i]+ruia[i])
    for i in range(m): ruib.append(b[i]+ruib[i])
    ans = 0
    j = m
    for i in range(n+1):
        if ruia[i] > k:
            break
        while(ruib[j]>k-ruia[i]):
            j -= 1
        ans = max(ans, i+j)
    print(ans)
    return 0

if __name__ == "__main__":
    solve()
n,k = map(int,input().split())
s = input()

zero = []
one = []
string = s[0]
if string == '0':
	flag = True
else:
	flag = False
count = 0
left = 0
right = 0
num = 0
for i in range(n):
	if s[i] == string:
		count += 1
	else:
		if string == '0':
			num = count
			string = '1'
		else:
			one.append(count)
			if num != 0:
				zero.append([num,left,count])
			string = '0'
			left = count
			num = 1
		count = 1

if string == '0':
	zero.append([num,left,0])
else:
	zero.append([num,left,count])
	one.append(count)
#print(zero)
#print(one)

res = 0
for i in range(k):
	res += zero[i][0] + zero[i][1]
res += zero[i][2]
#print(res)
ans = res
for i in range(len(zero)-k):
	res -= zero[i][0] + zero[i][1]
	#print(res)
	res += zero[i+k][0] + zero[i+k][2]
	#print(res)
	ans = max(ans,res)
print(ans)

### FIXED CODE ###

import sys

n,k = map(int,input().split())
s = input()

zero = []
one = []
string = s[0]
if string == '0':
	flag = True
else:
	flag = False
count = 0
left = 0
right = 0
num = 0
for i in range(n):
	if s[i] == string:
		count += 1
	else:
		if string == '0':
			num = count
			string = '1'
		else:
			one.append(count)
			if num != 0:
				zero.append([num,left,count])
			string = '0'
			left = count
			num = 1
		count = 1

if string == '0':
	zero.append([count,left,0])
else:
	zero.append([num,left,count])
	one.append(count)
#print(zero)
#print(one)
if len(zero) <= k:
	print(len(s))
	sys.exit()
res = 0
for i in range(k):
	res += zero[i][0] + zero[i][1]
res += zero[i][2]
#print(res)
ans = res
for i in range(len(zero)-k):
	res -= zero[i][0] + zero[i][1]
	#print(res)
	res += zero[i+k][0] + zero[i+k][2]
	#print(res)
	ans = max(ans,res)
print(ans)
import math

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

def f(m, a):
    re = 0
    for i in a:
        re += m % i
    return re

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

m = lcm_list(a) - 1
print(f(m, a))

### FIXED CODE ###

import fractions
from functools import reduce

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

def f(m, a):
    re = 0
    for i in a:
        re += m % i
    return re

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

m = lcm_list(a) - 1
print(f(m, a))
#dummy
#16:07
n = int(input())
raw = []
for _ in range(n):
  raw.append(list(map(lambda x: int(x)-1, input().split())))
cnt = [0 for _ in range(n)]
now = [i for i in range(n)]
ans = 0
while now:
  ans += 1
  last = now
  now = []
  tmp = [0 for _ in range(n)]
  for x in last:
    if cnt[x] < n-1:
      y = raw[x][cnt[x]]
      if tmp[x] == tmp[y] == 0 and x == raw[y][cnt[y]]:
        cnt[x] += 1
        cnt[y] += 1
        tmp[x] = 1
        tmp[y] = 1
        now.append(x)
        now.append(y)
  #print(now)
  if n > 500 and cnt[0] == 10:
    break
if cnt == [n-1 for _ in range(n)]:
  print(ans-1)
else:
  print(-1)

### FIXED CODE ###

a = input()
b = input()
ans = 0
for i in range(3):
  if a[i] == b[i]:
    ans += 1
print(ans)
import numpy as np

def is_symmetric(a):
    return np.array_equal(a, a.T)

def main():
    N = int(input())
    S = [[] for _ in range(N)]
    for i in range(N):
        for s in list(input()):
            S[i].append(ord(s) - ord("a"))

    S = np.array(S)

    ans = 0
    for A in range(N):
        for B in range(N):
            if is_symmetric(np.roll(S, (A, B), axis=(0,1))):
                ans += 1

    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

# 解説AC
import numpy as np

def is_symmetric(a):
    """
    対象行列判定 O(N * N)
    """
    return np.array_equal(a, a.T)

def main():
    N = int(input())
    S = [[ord(s) - ord("a") for s in list(input())] for _ in range(N)]

    S = np.array(S)

    ans = 0
    for B in range(N):
        if is_symmetric(np.roll(S, B, axis=1)):
            ans += N

    print(ans)

if __name__ == "__main__":
    main()
import math

str=input()
n,k=int(str.split()[0]),int(str.split()[1])

def place(n,x):
    if n==1:
        return 1
    ans=1
    if n-1 < x:
        for i in range(x+1,n+x):
            ans*=i
        ans//=math.factorial(n-1)
    else:
        for i in range(n, n+x):
            ans*=i
        ans//=math.factorial(x)
    return ans%1000000007

for i in range (1,k+1):
    cb=place(  i,  k-i  )
    cr=place(i+1,n-k-i+1)
    print(cb*cr%1000000007)


### FIXED CODE ###

import math

str=input()
n,k=int(str.split()[0]),int(str.split()[1])

def place(n,x):
    if n==1:
        return 1
    ans=1
    if n-1 < x:
        for i in range(x+1,n+x):
            ans*=i
        ans//=math.factorial(n-1)
    else:
        for i in range(n, n+x):
            ans*=i
        ans//=math.factorial(x)
    return ans%1000000007


for i in range (1,k+1):
    if n-k < i-1:
        print(0)
    else:
        cb=place(  i,  k-i  )
        cr=place(i+1,n-k-i+1)
        cr=cr%1000000007
        print(cb*cr%1000000007)
N,M = map(int,input().split())
sc = [[0,0]]*M
ans = [0]*N
f = True
for i in range(M):
    sc[i] = list(map(int,input().split()))

for i in range(M):
    ans[sc[i][0]-1] = str(sc[i][1])

sc.sort()
for i in range(M-1):
    if (sc[i][0] == sc[i+1][0]):
        if (sc[i][1] != sc[i+1][1]):
            f = False

if (f):
    for i in range(M):
        ans[i] = str(ans[i])

    if (ans[0] == "0"):
        if (N == 1):
            print(0)
        else:
            print(-1)
    else:
        print("".join(ans))
else:
    print(-1)

### FIXED CODE ###

N,M = map(int,input().split())
sc = [[0,0]]*M
ans = [0]*N
f = True
ans = -1
for i in range(M):
    sc[i] = list(map(int,input().split()))

for i in range(1000):
    str_i = list(str(i))
    if (len(str_i) == N):
        f = True
        for j in range(M):
            f &= (str_i[sc[j][0]-1] == str(sc[j][1]))
        if (f):
            ans = i
            break

print(ans)
N = int(input())
A = list(map(int, input().split()))
#A = [int(x) for x in input().split()]
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

total = 0

for i in range(N):
    low = 0
    high = N + 1
    while low + 1 < high:
        mid1 = (low + high) // 2
        if A[mid1] < B[i]:
            low = mid1
        if A[mid1] >= B[i]:
            high = mid1
    mid1 = low
    low = -1
    high = N
    while low + 1 < high:
        mid2 = (low + high) // 2
        if C[mid2] <= B[i]:
            low = mid2
        if C[mid2] > B[i]:
            high = mid2
    mid2 = high
    total = total + (mid1 + 1) * (N - mid2)

print(total)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
#A = [int(x) for x in input().split()]
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
A = [-float('inf')] + A + [float('inf')]
B.sort()
C.sort()
C = [-float('inf')] + C + [float('inf')]

total = 0

for i in range(N):
    low = 0
    high = N + 1
    while high - low > 1:
        mid1 = (low + high) // 2
        if A[mid1] < B[i]:
            low = mid1
        else:
            high = mid1
    mid1 = low
    low = 0
    high = N + 1
    while high - low > 1:
        mid2 = (low + high) // 2
        if C[mid2] <= B[i]:
            low = mid2
        else:
            high = mid2
    mid2 = high
    total += mid1 * (N + 1 - mid2)

print(total)
a,b,n=map(int,input().split())
m=0
for i in range(1,n+1,n-1):
    c=a*i//b-a*(i//b)
    if c>=m:
        m=c
    # print((a*i)//b,a*(i//b),a*i//b-a*(i//b))
print(m) 

### FIXED CODE ###

a,b,n=map(int,input().split())
if b-1<=n:
    i=b-1
else:
    i=n
print(a*i//b-a*(i//b))
from math import sqrt, isclose, floor
N, D = [int(elem) for elem in input().split()]
coords = [[int(elem) for elem in input().split()] for _ in range(N)]
assert len(coords[0]) == D

num_pairs = 0
for i in range(N):
    c1 = coords[i]
    for j in range(i + 1, N):
        c2 = coords[j]
        sqaured_dist = sum((p1 - p2) ** 2 for p1, p2 in zip(c1, c2))
        dist = floor(sqrt(sqaured_dist))
        if sqaured_dist // dist == dist:
            num_pairs += 1
print(num_pairs)


### FIXED CODE ###

N, D = [int(elem) for elem in input().split()]
coords = [[int(elem) for elem in input().split()] for _ in range(N)]
assert len(coords[0]) == D

def is_squared(num):
    i = 1
    while i * i <= num:
        if i * i == num:
            return True
        i += 1
    return False


num_pairs = 0
for i in range(N):
    c1 = coords[i]
    for j in range(i + 1, N):
        c2 = coords[j]
        sqaured_dist = sum((p1 - p2) ** 2 for p1, p2 in zip(c1, c2))
        if is_squared(sqaured_dist):
            num_pairs += 1
print(num_pairs)
import itertools

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

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

def dfs(h,w,parent):
  if parent:
    VALID[h][w] = True

  nxt = [-1,0,1]
  ok = False
  for x,y in itertools.product(nxt,repeat=2):
    if not (abs(x) + abs(y) == 1):
      continue
    nx = h + x
    ny = w + y
    if 0 <= nx < H and 0 <= ny < W and S[nx][ny] == '#' and not VALID[nx][ny]:
      ok = True
      dfs(nx,ny,True)
  
  if not parent and ok:
    VALID[h][w] = True
      
for i in range(H):
  for j in range(W):
    if S[i][j] == '.':
      VALID[i][j] = True
    else:
      if not VALID[i][j]:
        dfs(i,j,False)
        
if all(sum(VALID,[])):
  print('Yes')
else:
  print('No')


### FIXED CODE ###

import itertools

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

ok = True        
for i in range(H):
  for j in range(W):
    if S[i][j] == '#':
      flg = False
      for x,y in itertools.product([-1,0,1],repeat=2):
        if not (abs(x) + abs(y) == 1):
          continue
        nx = i + x;ny = j + y
        if 0 <= nx < H and 0 <= ny < W:
          if S[nx][ny] == '#':
            flg = True
      if not flg:
        ok = False
        break
if ok:
  print('Yes')
else:
  print('No')
from itertools import groupby
N=int(input())
s=input()
print(len(groupby(s)))

### FIXED CODE ###

N=int(input())
S=input()
for i in range(1,len(S)):
  if S[i]==S[i-1]:
    N-=1
print(N)
N = input().split(" ")
h = map(int,input().split())
h = list(h)

dp = [99999999 for i in range(100)]
dp[0]=0

for i in range(int(N[0])):
    for j in [i+1,i+N[1]]:
        if j<int(N) :
            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]))

print(dp[int(N)-1])

### FIXED CODE ###

import sys
n =int(input())
h = map(int,input().split())
h = list(h)

dp = [sys.maxsize]*n
dp[0]=0

for i in range(n):
    for j in range(i+1,i+2+1):
        if j<n :
            dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]))

print(dp[n-1])
A,B,T=map(int, float(input()))
print(int((T+0.5)//A*B))

### FIXED CODE ###

A,B,T=(map(float, input().split())) 
print(int((T+0.5)//A*B))
import math
r = int(input())
s = r * r * math.pi
l = r * 2.0 * math.pi
print("{:f} {:f}".format(s, l))



### FIXED CODE ###

import math
r = float(input())
s = r * r * math.pi
l = r * 2.0 * math.pi
print("{:f} {:f}".format(s, l))
#38
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
last = 9
time = 0
cou = 0
#l = [[A,"A"],[B,"B"],[C,"C"],[D,"D"],[E,"E"]]
l = [A,B,C,D,E]
for i in l:
    if i%10 !=0 :
        if last%10 >= i%10:
            last = i

l.remove(last)
l.append(last)
for i in range(5):
    time += l[i]
    if i == 4:
        break
    while time%10 != 0:
        time += 1
        
    
print(time)
        

### FIXED CODE ###

#38
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
last = 9
time = 0
cou = 0
check = 0
#l = [[A,"A"],[B,"B"],[C,"C"],[D,"D"],[E,"E"]]
l = [A,B,C,D,E]
for i in l:
    if i%10 !=0 :
        if last%10 >= i%10:
            last = i
            check +=1
if check !=0:
    l.remove(last)
    l.append(last)
for i in range(5):
    time += l[i]
    if i == 4:
        break
    while time%10 != 0:
        time += 1
        
    
print(time)
def move(x1, y1, x2, y2):
  number = abs(x1-x2)+abs(y1-y2)
  result = []
  while x1 > x2:
    result.append([x1, y1, x1-1, y1])
    x1 -= 1
  while x1 < x2:
    result.append([x1, y1, x1+1, y1])
    x1 += 1
  while y1 > y2:
    result.append([x1, y1, x1, y1-1])
    y1 -= 1
  while y1 < y2:
    result.append([x1, y1, x1, y1+1])
    y1 += 1
  return number, result


H,W = map(int, input().split())
a = [[j%2 for j in range(w)] for i in range(h)]
b = 0
x1, y1 = 0,0
n = 0
moved = []
for x,i in enumerate(a):
  x += 1
  for y,j in enumerate(i):
    y += 1
    if j:
      if b:
        d = move(x1,y1,x,y)
        n += d[0]
        moved += d[1]
        b = 0
      else:
        x1, y1 = x,y
        b = 1
print(n)        
for i in moved:
  print(*i)

### FIXED CODE ###

def move(moves):
  b = []
  for (y1,x1),(y2,x2) in zip(moves[:-1],moves[1:]):
    b.append((y1,x1,y2,x2))
  return b

h,w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
now = 0
moves = []
ans = []
for y,coins in enumerate(a,1):
  if y % 2:
    for x,coin in enumerate(coins,1):
      if now:
        moves.append((y,x))
        if coin % 2:
          b = move(moves)
          ans += b
          moves = []
          now = 0
      else:
        if coin % 2:
          moves.append((y,x))
          now = 1
  else:
    for x,coin in enumerate(coins[::-1]):
      x = w - x
      if now:
        moves.append((y,x))
        if coin % 2:
          b = move(moves)
          ans += b
          moves = []
          now = 0
      else:
        if coin % 2:
          moves.append((y,x))
          now = 1
print(len(ans))
for i in ans:
  print(*i)
K = int(input())
A, B = map(int, input().split())
i = A // K
nk = K
OK = False
if A-B >= K:
  print('OK')
else:
  while nK < B:
    if (nK >= A) and (nK <= B):
      OK = True
      print('OK')
    nK = i * K
    i = i + 1
if OK == False:
  print('NG')

### FIXED CODE ###

K = int(input())
A, B = map(int, input().split())
i = A // K
nK = K
OK = False
if A-B > K:
  print('OK')
else:
  while nK <= B:
    if (nK >= A) and (nK <= B):
      OK = True
      print('OK')
      break
    nK = i * K
    i = i + 1
if OK == False:
  print('NG')
a,b = map(int,input().split())
if a%2==0 or b%==0:
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

a,b = map(int,input().split())
if a%2==0 or b%2==0:
  print("Even")
else:
  print("Odd")
n, m, x, y = map(int, input().split())
xs = input().split()
ys = input().split()

for i in range(n):
    xs[i] = int(xs[i])

for i in range(m):
    ys[i] = int(ys[i])

if max(xs) < min(ys):
    print("No War")
else:
    print("War")

### FIXED CODE ###

l = input().split()
for i in range(len(l)):
    l[i] = int(l[i])
    
l.sort()
print(l[2] * 10 + l[1] + l[0])
import numpy as np
#, K = map(int, input().split())

K = int(input())
S = input()

if len(S) <= K:
    print(S)
else:
    print(S[:K] + '...')

### FIXED CODE ###

K = int(input())
S = input()
 
if len(S) <= K:
    print(S)
else:
    print(S[:K] + '...')
MOD = 10**9+7
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if all(ai < 0 for ai in a):
    ans = 1
    if k & 1:
        for ai in a[-k:]:
            ans = ans * ai % MOD
    else:
        for ai in a[:k]:
            ans = ans * ai % MOD
elif n == k:
    ans = 1
    for ai in a:
        ans = ans * ai % MOD
else:
    ans = 1
    a.sort(key=abs, reverse=True)
    cneg = sum(ai < 0 for ai in a[:k])
    if cneg & 1 == 0:
        for ai in a[:k]:
            ans = ans * ai % MOD
    else:
        left = []
        cnt = 0
        for i in range(len(a)):
            if cneg == 1:
                if i < k - 1 and a[i] >= 0:
                    ans = ans * ai % MOD
                    cnt += 1
                else:
                    left.append(a[i])
            else:
                ans = ans * a[i] % MOD
                cnt += 1
                if a[i] < 0:
                    cneg -= 1
        r = k - cnt
        if r == 1:
            ans = ans * [ai for ai in left if ai >= 0][0] % MOD
        else:
            ngs = [ai for ai in left if ai < 0]
            pss = [ai for ai in left if ai >= 0]
            t = -1001001001001001001001
            if len(ngs) >= 2:
                t = ngs[0] * ngs[1]
            if len(pss) >= 2:
                t = max(t, pss[0] * pss[1])
            ans = ans * t % MOD
print(ans)




### FIXED CODE ###

MOD = 10**9+7
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if all(ai < 0 for ai in a):
    ans = 1
    if k & 1:
        for ai in a[-k:]:
            ans = ans * ai % MOD
    else:
        for ai in a[:k]:
            ans = ans * ai % MOD
elif n == k:
    ans = 1
    for ai in a:
        ans = ans * ai % MOD
else:
    ans = 1
    a.sort(key=abs, reverse=True)
    cneg = sum(ai < 0 for ai in a[:k])
    cpos = sum(ai >= 0 for ai in a[:k])
    if cneg & 1 == 0:
        for ai in a[:k]:
            ans = ans * ai % MOD
    else:
        left = []
        r = k
        for ai in a:
            if ai < 0 and cneg > 1:
                ans = ans * ai % MOD
                cneg -= 1
                r -= 1
            elif ai >= 0 and cpos > 1:
                ans = ans * ai % MOD
                cpos -= 1
                r -= 1
            else:
                left.append(ai)
        ngs = [ai for ai in left if ai < 0]
        pss = [ai for ai in left if ai >= 0]
        if r == 1:
            ans = ans * pss[0] % MOD
        else:
            t = -1001001001001001001001
            if len(ngs) >= 2:
                t = ngs[0] * ngs[1]
            if len(pss) >= 2:
                t = max(t, pss[0] * pss[1])
            ans = ans * t % MOD
print(ans)
s = input()
print chr(ord(s) + 1)

### FIXED CODE ###

s = input()
print(chr(ord(s) + 1))