from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import random
import math
import time
import bisect
from functools import lru_cache
import itertools

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    start_time = time.time()
    D = int(input())
    c = [int(a) for a in input().split()]
    s = [
        [int(a) for a in input().split()]
        for _ in range(D)
    ]

    def calc_score(t):
        score = 0
        last = [0] * len(c)
        res = []

        for d, ti in enumerate(t):
            sdi = s[d][ti - 1]
            score += sdi
            last[ti - 1] = d + 1
            for i, ci in enumerate(c):
                score -= ci * ((d + 1) - last[i])
            res.append(score)
        return res

    def calc_score_diff(t, di, qi):
        old_q = t[di - 1]
        last_old_q_date = 0
        for i in range(di - 2, -1, -1):
            if t[i] == old_q:
                last_old_q_date = i + 1
                break
        next_old_q_date = D + 1
        for i in range(di, D):
            if t[i] == old_q:
                next_old_q_date = i + 1
                break

        old_d_last = di - last_old_q_date
        old_d_next = next_old_q_date - di
        old_diff = old_d_next * old_d_last * c[old_q - 1]

        new_q = qi
        last_new_q_date = 0
        for i in range(di - 2, -1, -1):
            if t[i] == new_q:
                last_new_q_date = i + 1
                break
        next_new_q_date = D + 1
        for i in range(di, D):
            if t[i] == new_q:
                next_new_q_date = i + 1
                break

        new_d_last = di - last_new_q_date
        new_d_next = next_new_q_date - di
        new_diff = new_d_next * new_d_last * c[new_q - 1]

        old_score = s[di - 1][old_q - 1]
        new_score = s[di - 1][new_q - 1]
        return new_diff - old_diff + new_score - old_score

    t = [1] * D
    score = calc_score(t)[-1]
    update_count = 0
    aa = 0
    best_t = [a for a in t]
    best_score = score
    ii = 0
    while True:
        ii += 1
        elapsed_time = time.time() - start_time
        if elapsed_time > 1.7:
            break

        di = random.randint(1, D)
        # qi = random.randint(1, len(c))
        p = 0.1
        if random.random() < p:
            qi = random.randint(1, len(c))
        else:
            qi = 1
            max_diff = 0
            for i in range(len(c)):
                diff = calc_score_diff(t, di, i + 1)
                if diff > max_diff:
                    max_diff = diff
                    qi = i + 1

        diff = calc_score_diff(t, di, qi)
        if diff > 0:
            score += diff
            t[di - 1] = qi
            if score > best_score:
                best_t = [a for a in t]
                best_score = score
            update_count += 1
            aa = 0
        else:
            aa += 1
            if aa > 500:
                # print(update_count, ii, best_score, file=sys.stderr)
                # exit(0)
                for i in range(10):
                    di = random.randint(1, D)
                    qi = random.randint(1, len(c))
                    t[di - 1] = qi
                aa = 0

    for ti in best_t:
        print(ti)


if __name__ == "__main__":
    main()


Measured memory_bytes: 87464