Harryxun/stf_run huggingface dataset:
n , m , q = map(int,input().split())
p = []
for i in range(q):
    a , b , c , d = map(int,input().split())
    p.append([a,b,c,d])
ans = 0
for a1 in range(1,m+1):
    for a2 in range(a1,m+1):
        for a3 in range(a2,m+1):
            for a4 in range(a3,m+1):
                for a5 in range(a4,m+1):
                    for a6 in range(a5,m+1):
                        for a7 in range(a6,m+1):
                            for a8 in range(a7,m+1):
                                for a9 in range(a8,m+1):
                                    for a10 in range(a9,m+1):
                                        tyu = [a1,a2,a3,a4,a5,a6,a7,a8,a9,a10]
                                        kar = 0
                                        for x,y,z,w in p:
                                            if tyu[y] - tyu[x] == z:
                                                kar += w
                                        ans = max(kar,ans)
print(ans)
                                        
                        

### FIXED CODE ###

n , m , q = map(int,input().split())
p = []
for i in range(q):
    a , b , c , d = map(int,input().split())
    p.append([a,b,c,d])
ans = 0
for a1 in range(1,m+1):
    for a2 in range(a1,m+1):
        for a3 in range(a2,m+1):
            for a4 in range(a3,m+1):
                for a5 in range(a4,m+1):
                    for a6 in range(a5,m+1):
                        for a7 in range(a6,m+1):
                            for a8 in range(a7,m+1):
                                for a9 in range(a8,m+1):
                                    for a10 in range(a9,m+1):
                                        tyu = [0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10]
                                        kar = 0
                                        for x,y,z,w in p:
                                            if tyu[y] - tyu[x] == z:
                                                kar += w
                                        ans = max(kar,ans)
print(ans)
n, q = map(int, input().split())
edge = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

cost = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    cost[p-1] += x

ans = [0] * n
def dfs(cur, c, parent):
    c += cost[cur]
    ans[cur] = c
    for next in edge[cur]:
        if next != parent:
            dfs(next, c, cur)

dfs(0, 0, -1)
print(*ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)

n, q = map(int, input().split())

connect = [set() for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    connect[a-1].add(b-1)
    connect[b-1].add(a-1)

counter = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    counter[p-1] += x

ans = [0] * n
def dfs(me, parent, cum):
    cum += counter[me]
    ans[me] = cum
    for child in connect[me]:
        if child != parent:
            dfs(child, me, cum)

dfs(0, -1, 0)

print(*ans)
N = int(input())
i = 0
while 2**i <-=N:
  i += 1
  
print(2**(i-1))
  

### FIXED CODE ###

N = int(input())
i = 0
while 2**i <= N:
  i += 1
  
print(2**(i-1))
n = int(input())
d, x = int(input())
ans = x
for i in range(n):
	ans += (d - 1) // int(input()) + 1

print(ans)

### FIXED CODE ###

n = int(input())
d, x = map(int, input().split())
ans = x
for i in range(n):
	ans += (d - 1) // int(input()) + 1

print(ans)
N = int(input())

n1 = int(N / 100 % 100)
n2 = N % 100

if n1 > 12 and n2 > 0:
    print("YYMM")
elif n2 > 12 and n1 > 0:
    print("MMYY")
elif n1 < 13 and n2 < 13:
    print("AMBIGUOUS")
else:
    print("NA")


### FIXED CODE ###

n , k = map(int, input().split())
S = list(input())

for i in range(len(S)):
    if i == k - 1:
        print(S[i].swapcase(), end="")
    else:
        print(S[i], end="")
print()
a,b = map(int,input().split())
if b<=a:
  if a = 1 or a = 12 :
    print(a)
  else:
    print(a+1)
else:
  print(a)

### FIXED CODE ###

a,b = map(int,input().split())
c = a - 1
if b<a :
  print(c)
else:
  print(a)
S = input()

def is_keyence(S):
    keyence_str = "keyence"
    i = 0
    is_change = False
    change_num = 0
    for j in range(len(S)):
        print(i, j, S[j],keyence_str[i])
        if S[j] != keyence_str[i]:
            if is_change: change_num += 1
            else:
                if change_num > 0:
                    # 二回以上修正箇所がある
                    return False
                is_change = True
                change_num += 1
        else:
            if is_change: is_change = False
            i += 1
    if i == len(keyence_str):
        return True
    else: return False


if is_keyence(S):
    print("YES")
else:
    print("NO")

### FIXED CODE ###

S = input()

def is_keyence(S):
    key = "keyence"
    for i in range(len(key)):
        #print(key[:i], key[i:])
        if (S.startswith(key[:i]) and S.endswith(key[i:])):
            return True
    return False


if is_keyence(S):
    print("YES")
else:
    print("NO")
import numpy as np
from numba import njit

rr,cc,kk=map(int,input().split())
goods=np.array([list(map(int,input().split())) for _ in range(kk)],dtype=np.int)
gg=np.zeros((rr,cc),dtype=np.int)
for cr,ccc,ck in goods:
    gg[cr-1][ccc-1]=ck

@njit(cache=True)
def calc(r,c,g):
    dp=-1*np.ones((r+1,c+1,4),dtype=np.int)
    maxlst=np.zeros((r+1,c+1),dtype=np.int)

    dp[:,0,0]=0
    dp[0,:,0]=0
    
    for i in range(r):
        for j in range(c):
            tmp=0
            for k in range(3):
                if g[i][j]>0 and dp[i+1][j][k]>=0:
                    dp[i+1][j+1][k+1]=max(dp[i+1][j][k+1],dp[i+1][j][k]+g[i][j])
                else:
                    dp[i+1][j+1][k+1]=dp[i+1][j][k+1]
                tmp=max(tmp,dp[i+1][j+1][k+1])
            
            dp[i+1][j+1][0]=max(maxlst[i][j+1],dp[i+1][j][0])
            tmp=max(tmp,dp[i+1][j+1][0])
            
            if g[i][j]>0 and dp[i+1][j+1][0]>=0:
                dp[i+1][j+1][1]=max(dp[i+1][j+1][1],dp[i+1][j+1][0]+g[i][j])
                tmp=max(tmp,dp[i+1][j+1][1])
            
            maxlst[i+1][j+1]=tmp
    
    return maxlst[r][c]
            
print(calc(rr,cc,gg))

### FIXED CODE ###

import numpy as np
from numba import njit

rr,cc,kk=map(int,input().split())
goods=np.array([list(map(int,input().split())) for _ in range(kk)])
gg=np.zeros((rr,cc))
for cr,ccc,ck in goods:
    gg[cr-1][ccc-1]=ck

@njit
def calc(r,c,g):
    dp=-1*np.ones((r+1,c+1,4))
    maxlst=np.zeros((r+1,c+1))

    dp[:,0,0]=0
    dp[0,:,0]=0
    
    for i in range(r):
        for j in range(c):
            tmp=0
            for k in range(3):
                if g[i][j]>0 and dp[i+1][j][k]>=0:
                    dp[i+1][j+1][k+1]=max(dp[i+1][j][k+1],dp[i+1][j][k]+g[i][j])
                else:
                    dp[i+1][j+1][k+1]=dp[i+1][j][k+1]
                tmp=max(tmp,dp[i+1][j+1][k+1])
            
            dp[i+1][j+1][0]=max(maxlst[i][j+1],dp[i+1][j][0])
            tmp=max(tmp,dp[i+1][j+1][0])
            
            if g[i][j]>0 and dp[i+1][j+1][0]>=0:
                dp[i+1][j+1][1]=max(dp[i+1][j+1][1],dp[i+1][j+1][0]+g[i][j])
                tmp=max(tmp,dp[i+1][j+1][1])
            
            maxlst[i+1][j+1]=tmp
    
    return maxlst[r][c]
            
print(int(calc(rr,cc,gg)))
n = int(input())
    s = input()
    half = n//2
     
    if s == (s[0:half] + s[0:half]):
             print("Yes")
    else:
             print("No")

### FIXED CODE ###

n = int(input())
s = input()
half = n//2

if half == 0:
  				print("No")

elif s == (s[0:half] + s[0:half]):
                 print("Yes")
else:
                 print("No")
n, y = map(int, input().split())
for i in range(n+1):
  for g in range(n-i):
    s = n-i-g
    if 10000*i + 5000*g 1000*s == y:
      print(i, g, s)
      exit()
print('-1 -1 -1')

### FIXED CODE ###

n, y = map(int, input().split())
for i in range(n+1):
  for g in range(n-i+1):
    s = n-i-g
    if 10000*i + 5000*g + 1000*s == y:
      print(i, g, s)
      exit()
print('-1 -1 -1')
N = int(input())
fmax = int(N/4)+1
smax = int(N/7)+1
for i in range(fmax +1):
  for j in range(smax + 1):
	if (4*i + 7*j) == N:
	  print('Yes')
	  exit()
print('No')


### FIXED CODE ###

N = int(input())
fmax = int(N/4)+1
smax = int(N/7)+1
for i in range(fmax+1):
  for j in range(smax+1):
    if (4*i+7*j) == N:
      print('Yes')
      exit()
print('No')
S = str(input())

if ((S.count("N") !=0 and S.count("S") !=0) or (S.count("N") ==0 and S.count("S") ==0)) and
   ((S.count("W") !=0 and S.count("E") !=0) or (S.count("W") ==0 and S.count("E") ==0)):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

S = str(input())

if (S.count("N") !=0 and S.count("S") !=0) or (S.count("N") ==0 and S.count("S") ==0):
    if (S.count("W") !=0 and S.count("E") !=0) or (S.count("W") ==0 and S.count("E") ==0):
        print("Yes")
    else:
        print("No")
else:
    print("No")
N = int(input())
train = [[] for _ in range(N)]
take_time = []
for cnt in range(N - 1):
    x, y , z = map(int,input().split())
    take_time.append(x)
    for _ in range(10**3):
        train[cnt].append(y)
        y += z

from bisect import bisect_left
for place in range(N):
    now = 0
    for i in range(place,N - 1):
        index = bisect_left(train[i],now)
        now = train[i][index]
        now += take_time[i]
    print(now)



### FIXED CODE ###

N = int(input())
train = [[] for _ in range(N)]
L = []
for cnt in range(N - 1):
    l = list(map(int,input().split()))
    L.append(l)

from math import ceil

from bisect import bisect_left
for place in range(N):
    now = 0
    for i in range(place,N - 1):
        k = max(0,ceil((now - L[i][1]) / L[i][2]))
        now = L[i][1] + L[i][2] * k
        now += L[i][0]
    print(now)
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

N = int(input())
line = list(map(int,input().split()))
ans = gcd_list(line)

print(ans)

### FIXED CODE ###

def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

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

ans = line[0]

for i in range(1,n):
    ans = gcd(ans,line[i])

print(ans)
N=int(input())
S=["" for i in range(N)]

for i in range(N):
    S[i]=input()

count=0

for l in range(N):
    JUDGE=1
    for j in range(N):
        for k in range(j+1,N):
            
            if S[j][k-l]!=S[k][j-l]:
                JUDGE=0
                break
        if JUDGE==0:
            break

    if JUDGE==1:
        count+=1

print(count*N)


### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
 
count=0
score=0

SUM=[0 for i in range(N+1)]
SUM[0]=0
 
for i in range(1,N+1):
    SUM[i]=SUM[i-1]+A[i-1]

    
SUM.sort()



for i in range(1,N+1):
    if SUM[i]==SUM[i-1]:
        count=count+1
    else:
        if count!=0:
            score=score+count*(count+1)//2
        count=0
        
if count!=0:
    score=score+count*(count+1)//2

 
print(score)
li = []
for i in range(6):
    li.append(int(input()))

flag = "Yay!"
for i in range(len(li)-1):
    if li[i+1] - li[i] > li[5]:
        flag = ":("

return flag


### FIXED CODE ###

li = []
for i in range(6):
    li.append(int(input()))

flag = "Yay!"
if li[4] - li[0] > li[5]:
    flag = ":("

print(flag)
l=int(input())
print(L**3/27)

### FIXED CODE ###

l=int(input())
print(l**3/27)
import numpy as np

pi = np.pi

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

S = x/a

if S >= a*b/2:
    ans = np.arctan(a / 2 / (b - h)) / (2 * pi) * 360
elif S <= a*b/2:
    ans = np.arctan(b/(2*S/b)) / (2 * pi) * 360

print(ans)

### FIXED CODE ###

import numpy as np

pi = np.pi

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

S = x/a

if S >= a*b/2:
    h = x/(a**2)
    ans = np.arctan((b - h)/(a/2)) / (2 * pi) * 360
elif S <= a*b/2:
    ans = np.arctan(b/(2*S/b)) / (2 * pi) * 360

print(ans)
input()
print( x ** 3)

### FIXED CODE ###

x = int( input())
print( x ** 3)
import sys

n,m=input().split()
N = int(n)
M = int(m)
X = input().split()
#MはXの要素の数
X = [int(x) for x in X]

X.sort()
if M == 1:
    print(0)
    sys.exit()
elif M < 1:
    sys.exit()

minus = [X[i]-X[i-1] for i in range(1,M)]
#print(minus)

minus.sort()
#print(minus)
sum_num = 0
for i in range(N+1):
    sum_num += minus[i]
print(sum_num)

### FIXED CODE ###

import sys

n,m=input().split()
N = int(n)
M = int(m)
X = input().split()
#MはXの要素の数
X = [int(x) for x in X]

X.sort()
if M == 1:
    print(0)
    sys.exit()
elif M < 1:
    sys.exit()

minus = [X[i]-X[i-1] for i in range(1,M)]
#print(minus)

minus.sort()
#print(minus)
sum_num = 0
if N < M:
    for i in range(M-N):
        sum_num += minus[i]
    print(sum_num)
elif N >= M:
    print(0)
import numpy as np

N, W = map(int, input().split())
knap = []
for i in range(N):
    knap.append(tuple(map(int, input().split())))

s_val = sum([v for w, v in knap])
    
INF = float("inf")
dp = np.full(s_val+1, INF)

for i, (w, v) in enumerate(knap):
    dp[v:] = np.minimum(dp[v:], dp[:-v]+w)
    
print(max([i for i in range(s_val+1) if dp[i] <= W]))

### FIXED CODE ###

import numpy as np

N, W = map(int, input().split())
knap = []
for i in range(N):
    knap.append(tuple(map(int, input().split())))

s_val = sum([v for w, v in knap])
    
INF = float("inf")
dp = np.full(s_val+1, INF)
dp[0] = 0

for i, (w, v) in enumerate(knap):
    dp[v:] = np.minimum(dp[v:], dp[:-v]+w)
    
print(max([i for i in range(s_val+1) if dp[i] <= W]))
# coding:utf-8
import sys 
def main():
    input_list = list(map(int, input().split()))
    input_list.sort(reverse=True)
    
    diff = input_list[0] - input_list][1] + input_list[0] - input_list[2]
    ans = diff /2
    if diff % 2 == True:
        ans += 2

    print(ans) 
    
if __name__ == '__main__' :
    main()

### FIXED CODE ###

# coding:utf-8
import sys 
def main():
    input_list = list(map(int, input().split()))
    input_list.sort(reverse=True)
    
    diff = input_list[0] - input_list[1] + input_list[0] - input_list[2]
    ans = diff /2
    if diff % 2 == True:
        ans += 2

    print(int(ans))
    
if __name__ == '__main__' :
    main()
x = map(int, raw_input().split())
i = 1
while(1):
  if x[i] == 0:
    break
  print "Case %d: %d" %(i + 1, x[i])
  i += 1

### FIXED CODE ###

i = 1
while(1):
  x = int(raw_input())

  if x == 0:
    break

  print "Case %d: %d" %(i,x)
  i += 1
N = int(input())
arr = list(map(int, input().split()))
arr2 = [0]*(max(arr)+1)
for i in range(N):
    arr2[arr[i]] += 1
ans = arr2[1] + arr2[2] + arr2[3]
tmp = ans
for i in range(4,len(arr2)):
    tmp = tmp - arr2[i-3] + arr2[i]
    if ans < tmp:
        ans = tmp
print(ans)

### FIXED CODE ###

N = int(input())
arr = list(map(int, input().split()))
arr2 = [0]*(max(arr)+1)
if max(arr) < 4:
    print(len(arr))
    exit()
for i in range(N):
    arr2[arr[i]] += 1
ans = arr2[1] + arr2[2] + arr2[3]
tmp = ans
for i in range(4,len(arr2)):
    tmp = tmp - arr2[i-3] + arr2[i]
    if ans < tmp:
        ans = tmp
print(ans)
n = int(input())
a = list(map(int, input().split()))

if 0 in a:
  print(0)
  break

ans = 1
for i in a:
  ans *= i
  if ans > 10**18:
    print(-1)
    break

else:
print(ans)


### FIXED CODE ###

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

ans = 1
for i in a:
  ans *= i
  if ans > 10**18:
    print(-1)
    break

else:
    print(ans)
N= int(input())
S=[ input() for _ in range(N) ]

a=0
w=0
t=0
r=0

for i range(N):
  if S[i]=="AC":
    a+=1
  elif S[i]=="WA":
    w+=1
  elif S[i]=="TLE":
    t+=1
  elif S[i]=="RE":
    r+=1

print("AC x "　+ "str(a)")
print("WA x "　+ "str(w)")
print("TLE x "　+ "str(t)")
print("RE x "　+ "str(r)")


### FIXED CODE ###

N=int(input())
S=[input() for _ in range(N)]

a=0
w=0
t=0
r=0

for i in range(N):
  if S[i] =="AC":
    a+=1
  elif S[i] =="WA":
    w+=1
  elif S[i] =="TLE":
    t+=1
  elif S[i] =="RE":
    r+=1

print("AC x "+ str(a))
print("WA x "+ str(w))
print("TLE x "+ str(t))
print("RE x "+ str(r))
n,m=map(int,input().split())
l=[]
def nibutan(x,l):
    low=0
    high=len(l)-1
    while low<=high:
      mid=(low+high)//2
      guess=l[mid]
      if guess==x:
         return True
      elif guess>x:
          high=mid-1
      elif guess<x:
          low=mid+1
    return False
if m==0:
  pass
else:
  for i in range(m):
    l.append(int(input()))
l1=[0 for i in range(n)]
if 1 in l:
  l1[0]=0
else:
  l1[0]=1

if 2 in l:
  l1[1]=0
elif 1 in l:
  l1[1]=1
else:
  l1[1]=2

if n>=3:
  for i in range(3,n+1): 
    if nibutan(i,l):
      pass
    else:
      l1[i-1]=(l1[i-2]+l1[i-3])%(((10**9)+7))
print(l1[n-1])

### FIXED CODE ###

n,m=map(int,input().split())
l=[]
def nibutan(x,l):
    low=0
    high=len(l)-1
    while low<=high:
      mid=(low+high)//2
      guess=l[mid]
      if guess==x:
         return True
      elif guess>x:
          high=mid-1
      elif guess<x:
          low=mid+1
    return False
if m==0:
  pass
else:
  for i in range(m):
    l.append(int(input()))
l1=[0 for i in range(n+1)]
if 1 in l:
  l1[0]=0
else:
  l1[0]=1

if 2 in l:
  l1[1]=0
elif 1 in l:
  l1[1]=1
else:
  l1[1]=2

if n>=3:
  for i in range(3,n+1): 
    if nibutan(i,l):
      pass
    else:
      l1[i-1]=(l1[i-2]+l1[i-3])%(((10**9)+7))
print(l1[n-1])
n = int(input())
inf = float("inf")
road = [dict() for _ in range(n)]
for _ in range(n-1):
  a,b,c = map(int, input().split())
  road[a-1][b-1] = c
  road[b-1][a-1] = c
q,k = map(int, input().split())
dfs = [inf]*n
dfs[k-1] = 0

def dodfs(x):
  for i in road[x-1]:
    if dfs[i] == inf:
      dfs[i] = dfs[x-1] + road[x-1][i]
      dodfs(i)
  return
      
dodfs(k)
for _ in range(q):
  x,y = map(int, input().split())
  print(dfs[x-1] + dfs[y-1])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
n = int(input())
inf = float("inf")
road = [dict() for _ in range(n+1)]
for _ in range(n-1):
  a,b,c = map(int, input().split())
  road[a][b] = c
  road[b][a] = c
q,k = map(int, input().split())
dfs = [inf]*(n+1)
dfs[k] = 0
def dodfs(x):
  for i in road[x]:
    if dfs[i] == inf:
      dfs[i] = dfs[x] + road[x][i]
      dodfs(i)
  return   
dodfs(k)
for _ in range(q):
  x,y = map(int, input().split())
  print(dfs[x] + dfs[y])
S = int(input())
    # S == 10 ** 9 * i + mod
    i, mod = divmod(S, 10 ** 9)
    # 求めたいのは、10 ** 9 * i - modなるiとmodの組
    # mod == 0のときはそのまま
    if mod == 0:
        print(0, 0, 10 ** 9, mod, 1, i)
    # そうでないときはiをインクリしてmodの項を負にしてしまえばいい
    else:
        print(0, 0, 10 ** 9, 10 ** 9 * (i + 1) - S, 1, i + 1)

### FIXED CODE ###

def resolve():
    S=int(input())
    i,mod=divmod(S,10**9)
    if mod==0:
        print(0,0,10**9,mod,1,i)
    else:
        print(0,0,10**9,10**9*(i+1)-S,1,i+1)

resolve()
import math
n,m=map(int, input().split())
a=sorted(list(map(int, input().split())),reverse=True)
tot=0
rate=[0]*n
p=[0]*n

for i in range(n-1):
  rate[i]=math.log2(a[i]/a[i+1])
  
cur=0
while m>0:
  if rate[cur]>0:
    p[cur]+=1
    rate[cur]-=1
    m-=1
    if cur>0:
      rate[cur-1]+=1
      cur-=1
  else:
    if cur+1<n
      cur+=1
    else:
      p[cur+1]+=1
      rate[cur+1]-=1
      rate[cur]+=1
      cur-=1
  
for i in range(n):
  tot+=int(a[i]/(2**p[i]))
print(tot)

### FIXED CODE ###

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

for i in range(n):
    a[i]*=-1

heapq.heapify(a)
for _ in range(m):
    x=heapq.heappop(a)*(-1)
    x=x//2
    heapq.heappush(a,-x)

print(sum(a)*(-1))
import itertools
import heapq
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
a = list(map(int,input().split()))
if n>=2*k:
  a_plus = heapq.nlargest(k, a)
  a_minus = heapq.nsmallest(k, a)
  a_new = a_plus+a_minus
  comb = itertools.combinations(a_new,k)
else:
  comb = itertools.combinations(a,k)
  
l = []
for i in comb:
  l.append(list(i))
  
A = []
one = [1]*len(l)
for i in l:
  for j in range(k):
    one[i]*=l[i][j]
    A.append(one[i])
    
l_max = max(one)
waru = 10**9 + 7
 
mod = l_max % waru
print(mod)

### FIXED CODE ###

import sys
 
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = pow(10, 9)+7
zero = 0
plus = []
minus = []
for i in range(n):
  if a[i] == 0:
    zero += 1
  elif a[i] > 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
 
P, M = len(plus), len(minus)
plus.sort(reverse=True)
minus.sort()
ans = 1
if n == k:
  for i in range(n):
    ans *= a[i]
    ans %= mod
elif P+M < k:
  ans = 0
elif P == 0:
  if zero and k%2:
    ans = 0
  else:
    if k%2:
      minus.reverse()
    for i in range(k):
      ans *= minus[i]
      ans %= mod
else:
  q = 0
  if k%2:
    ans *= plus[0]
    ans %= mod
    q = 1
  judge = []
  for i in range((len(plus)-q)//2):
    judge.append(plus[2*i+q]*plus[2*i+q+1])
  for i in range(len(minus)//2):
    judge.append(minus[2*i]*minus[2*i+1])
  judge.sort(reverse=True)
  for i in range(k//2):
    ans *= (judge[i]%mod)
    ans %= mod
 
print(ans)
N,K = map(int,input().split())

def solve(n,k):
  cand = abs(n-k)
  if n <= cand:
    return n
  else:
    return solve(cand,k)

print(solve(N,K))

### FIXED CODE ###

N,K = map(int,input().split())

if N % K == 0:
  print(0)
else:
  q = N // K
  d = N - K*q
  print(min(d,abs(d-K)))
def chess(h,w):
  if (h+w) % 2 == 0:
    return '#'
  return '.'

while True:
  H, W = map(int, input().split())
  if H == 0 and W == 0:
    break
  for i in range(H):
    for j in range(W):
      print(chess(I,j)', end='')
    print()
  print()



### FIXED CODE ###

def chess(h,w):
  if (h+w) % 2 == 0:
    return '#'
  return '.'

while True:
  H, W = map(int, input().split())
  if H == 0 and W == 0:
    break
  for i in range(H):
    for j in range(W):
      print(chess(i,j), end='')
    print()
  print()
a = list(map(int, input(),split()))
ans = 1

for r in range(0,len(a)):
  ans *= a[r]
  
print(ans)

### FIXED CODE ###

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

ans = 1
if 0 in A:
  print(0)
  exit()
  
for r in A:
  ans *= r
  if ans > 1e18:
      print(-1)
      exit()
      
print(ans)
import sys
input = sys.stdin.readline

D = int(input())
cost = list(map(int, input().strip().split()))
S = [list(map(int, input().strip().split())) for _ in range(D)]

last_held = [-1 for i in range(26)]
ans = []
for date, daily_scores in enumerate(S):
    minus_score = 0
    for i in range(D):
        minus_score += cost[i] * (date - last_held[i])

    max_score = daily_scores[0] + cost[0] * (date - last_held[0])
    max_index = 0
    for i, daily_score in enumerate(daily_scores):
        tmp = daily_score + cost[i] * (date - last_held[i])
        if max_score < tmp:
            max_index = i
            max_score = tmp
    if max_score <= minus_score:
        tmp = 0
        max_index = 0
        for i in range(D):
           if tmp < cost[i] * (date - last_held[i]):
               tmp = cost[i] * (date - last_held[i])
               max_index = i
    last_held[max_index] = date
    ans.append(max_index+1)
print("\n".join(map(str, ans)))

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

last_held = [-1 for i in range(26)]
ans = []
for date, line in enumerate(S):
    max_score = line[0] - cost[0]*last_held[0]
    max_index = 0
    for i, score in enumerate(line):
        tmp = score - cost[i]*last_held[i]
        if max_score < tmp:
            max_index = i
            max_score = tmp
    last_held[max_index] = date
    ans.append(max_index+1)
print("\n".join(map(str, ans)))