from bisect import bisect_left, bisect_right
from random import randint

class Set(): #BinaryIndexedTree
    def __init__(self, valuelist, INF=10**18+1):
        self.n = len(valuelist) + 1
        self.value = sorted(valuelist) + [INF]
        self.comp = {v : k for k, v in enumerate(self.value, 1)}
        self.bit = BinaryIndexedTree(self.n)

    def insert(self, x, k=1):
        self.bit.add(self.comp[x], k)

    def delete(self, x, k=1):
        self.bit.add(self.comp[x], -k)

    def count(self, x):
        return self.bit.get(self.comp[x])

    def sum(self, x):
        return self.bit.sum(self.comp[x])

    def get(self, k): #k個以下のときはINFを返す
        return self.value[self.bit.bisect_left(k) - 1]

class BinaryIndexedTree(): #1-indexed
    def __init__(self, n):
        self.n = n
        self.tree = [0 for _ in range(n + 1)]

    def sum(self, idx):
        res = 0
        while idx:
            res += self.tree[idx]
            idx -= idx & -idx
        return res

    def get(self, idx):
        return self.sum(idx) - self.sum(idx - 1)

    def add(self, idx, x):
        while idx <= self.n:
            self.tree[idx] += x
            idx += idx & -idx

    def bisect_left(self, x):
        if x <= 0: return 0
        res, tmp = 0, 2**((self.n).bit_length() - 1)
        while tmp:
            if res + tmp <= self.n and self.tree[res + tmp] < x:
                x -= self.tree[res + tmp]
                res += tmp
            tmp >>= 1
        if res >= self.n:
            return self.n
        return res + 1

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

D = 365
C = [randint(0, 100) for _ in range(D)]
S = [[randint(0, 200000) for j in range(26)] for i in range(D)]

res = 0
last = [0 for _ in range(26)]
T = [0 for _ in range(D)]
used = [Set(list(range(D))) for i in range(26)]

for d in range(D):
    maxtmp = -10**18
    contest = None
    for i in range(26):
        tmp = res
        lasttmp = last[:]
        tmp += S[d][i]
        lasttmp[i] = d + 1
        for j in range(26):
            tmp -= C[j] * ((d + 1) - lasttmp[j])
        if maxtmp <= tmp:
            maxtmp = tmp
            contest = i
    res += S[d][contest]
    last[contest] = d + 1
    used[contest].insert(d)
    for j in range(26):
        res -= C[j] * ((d + 1) - last[j])
    T[d] = contest + 1

for i in range(200000):
    tmp = res
    d = randint(1, D)
    q = randint(1, 26)
    if T[d - 1] == q:
        continue
    tmp -= S[d - 1][T[d - 1] - 1]
    tmp += S[d - 1][q - 1]
    k = used[T[d - 1] - 1].sum(d - 1)
    l = used[T[d - 1] - 1].get(k - 1) if k != 1 else -1
    r = used[T[d - 1] - 1].get(k + 1)
    if r == 1000000000000000001:
        r = D
    tmp -= (d - 1 - l) * C[T[d - 1] - 1] * (r - d + 1)
    used[T[d - 1] - 1].delete(d - 1)
    used[q - 1].insert(d - 1)
    k = used[q - 1].sum(d - 1)
    l = used[q - 1].get(k - 1) if k != 1 else -1
    r = used[q - 1].get(k + 1)
    if r == 1000000000000000001:
        r = D
    tmp += (d - 1 - l) * C[q - 1] * (r - d + 1)
    if tmp > res:
        res = tmp
        T[d - 1] = q
    else:
        used[T[d - 1] - 1].insert(d - 1)
        used[q - 1].delete(d - 1)

for r in T:
    print(r)

Measured memory_bytes: 98292