#pragma region Macro
#pragma region Basic
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i < i##_len; i++)
#define FORD(i, a, b) for (int i = (a), i##_len = (b); i > i##_len; i--)
#define FORR(t, a) for (auto t : a)
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define GET(i, j) get<j>(i)
#define MT(x, ...) make_tuple(x, __VA_ARGS__)
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x, 0, sizeof(x))
#define FILL(x, y) memset(x, y, sizeof(x))
#define PB push_back
#ifdef _DEBUG
#define PRE_COMMAND             \
    std::cin.rdbuf(in.rdbuf()); \
    cout << fixed << setprecision(15);
#else
#define PRE_COMMAND cout << fixed << setprecision(15);
#endif
const double EPS = 1e-10;
const double PI = acos(-1.0);
template <class T>
auto MAX(T& seq) {
    return *max_element(seq.begin(), seq.end());
}
template <class T>
auto MIN(T& seq) {
    return *min_element(seq.begin(), seq.end());
}
template <class T>
auto SUM(T& seq) {
    T temp{0};
    auto& temp2 = temp[0];
    return accumulate(seq.begin(), seq.end(), temp2);
}
template <class T>
void SORT(T& seq) {
    sort(seq.begin(), seq.end());
}
template <class T, class S>
void SORT(T& seq, S& sort_order) {
    sort(seq.begin(), seq.end(), sort_order);
}
template <class T>
void SORTR(vector<T>& seq) {
    sort(seq.begin(), seq.end(), greater<T>());
}
template <class T>
void CHMAX(T& a, const T& b) {
    if (a < b) { a = b; }
}
template <class T>
void CHMIN(T& a, const T& b) {
    if (b < a) { a = b; }
}
template <class T>
set<T> VECTOR_2_SET(vector<T>& v) {
    set<T> s;
    for (auto ele : v) { s.insert(ele); }
    return s;
}
template <class T>
vector<T> SET_2_VECTOR(set<T>& s) {
    vector<T> v;
    for (auto ele : s) { v.push_back(ele); }
    return v;
}
#pragma endregion Basic
#pragma region overload
template <class T, class S>
void operator+=(vector<T>& l, S& r) {
    for (auto i : r) { l.push_back(i); }
}
template <class T, class S>
void operator+=(set<T>& l, S& r) {
    for (auto i : r) { l.insert(i); }
}
template <class T, class S>
void operator+=(multiset<T>& l, S& r) {
    for (auto i : r) { l.insert(i); }
}
template <class T, class S>
vector<T> operator+(vector<T>& l, S& r) {
    vector<T> l_copy = l;
    for (auto i : r) { l_copy.push_back(i); }
    return l_copy;
}
template <class T>
vector<T> operator+(const vector<T> l, const vector<T>& r) {
    vector<T> l_copy = l;
    for (auto i : r) { l_copy.push_back(i); }
    return l_copy;
}
template <class T, class S>
set<T> operator+(set<T>& l, S& r) {
    set<T> l_copy = l;
    for (auto i : r) { l_copy.insert(i); }
    return l_copy;
}
template <class T>
set<T> operator+(const set<T> l, const set<T>& r) {
    set<T> l_copy = l;
    for (auto i : r) { l_copy.insert(i); }
    return l_copy;
}
template <class T, class S>
multiset<T> operator+(multiset<T>& l, S& r) {
    set<T> l_copy = l;
    for (auto i : r) { l_copy.insert(i); }
    return l_copy;
}
template <class T>
multiset<T> operator+(const multiset<T> l, const set<T>& r) {
    set<T> l_copy = l;
    for (auto i : r) { l_copy.insert(i); }
    return l_copy;
}
string operator+(const string l, const string& r) {
    string str = l;
    str += r;
    return str;
}
string operator*(const string l, const size_t& r) {
    string str = l;
    for (size_t i = 0; i < r; i++) { str += l; }
    return str;
}
#pragma endregion overload
#pragma region Input
template <class Head>
void INPUT(vector<Head>& head);
template <size_t N, class Head>
void INPUT(array<Head, N>& head);
template <class T1>
void INPUT(tuple<T1>& t);
template <class T1, class T2>
void INPUT(tuple<T1, T2>& t);
template <class T1, class T2, class T3>
void INPUT(tuple<T1, T2, T3>& t);
template <class T1, class T2, class T3, class T4>
void INPUT(tuple<T1, T2, T3, T4>& t);
template <class T1, class T2, class T3, class T4, class T5>
void INPUT(tuple<T1, T2, T3, T4, T5>& t);
template <class Head>
void INPUT(Head& head);
template <class Head, class... Tail>
void INPUT(Head& head, Tail&... tail);
//本体
template <class Head>
void INPUT(vector<Head>& head) {
    for (size_t i = 0; i < head.size(); i++) { INPUT(head[i]); }
}
template <size_t N, class Head>
void INPUT(array<Head, N>& head) {
    for (size_t i = 0; i < head.size(); i++) { INPUT(head[i]); }
}
template <class T1>
void INPUT(tuple<T1>& t) {
    cin >> get<0>(t);
}
template <class T1, class T2>
void INPUT(tuple<T1, T2>& t) {
    cin >> get<0>(t) >> get<1>(t);
}
template <class T1, class T2, class T3>
void INPUT(tuple<T1, T2, T3>& t) {
    cin >> get<0>(t) >> get<1>(t) >> get<2>(t);
}
template <class T1, class T2, class T3, class T4>
void INPUT(tuple<T1, T2, T3, T4>& t) {
    cin >> get<0>(t) >> get<1>(t) >> get<2>(t) >> get<3>(t);
}
template <class T1, class T2, class T3, class T4, class T5>
void INPUT(tuple<T1, T2, T3, T4, T5>& t) {
    cin >> get<0>(t) >> get<1>(t) >> get<2>(t) >> get<3>(t) >> get<4>(t);
}
template <class Head>
void INPUT(Head& head) {
    cin >> head;
}
template <class Head, class... Tail>
void INPUT(Head& head, Tail&... tail) {
    INPUT(head);
    INPUT((tail)...);
}
#pragma endregion Input
#pragma region Print
template <class T1>
void PRINT2(tuple<T1> t);
template <class T1, class T2>
void PRINT2(tuple<T1, T2> t);
template <class T1, class T2, class T3>
void PRINT2(tuple<T1, T2, T3> t);
template <class T1, class T2, class T3, class T4>
void PRINT2(tuple<T1, T2, T3, T4> t);
template <class T1, class T2, class T3, class T4, class T5>
void PRINT2(tuple<T1, T2, T3, T4, T5> t);
template <class Head>
void PRINT2(vector<Head> head);
template <class Head>
void PRINT2(vector<vector<Head>> head);
template <size_t N, class Head>
void PRINT2(vector<array<Head, N>> head);
template <class... Head>
void PRINT2(vector<tuple<Head...>> head);
template <size_t N, class Head>
void PRINT2(array<Head, N> head);
template <class Head>
void PRINT2(Head head);
template <class Head, class... Tail>
void PRINT2(Head head, Tail... tail);
template <class Head>
void PRINT(Head head);
template <class... Head>
void PRINT(Head... head);
template <int N, class Head>
void PRINT(Head head);
template <class T1>
void PRINT2(tuple<T1> t) {
    PRINT2(get<0>(t));
}
template <class T1, class T2>
void PRINT2(tuple<T1, T2> t) {
    PRINT2(get<0>(t), get<1>(t));
}
template <class T1, class T2, class T3>
void PRINT2(tuple<T1, T2, T3> t) {
    PRINT2(get<0>(t), get<1>(t), get<2>(t));
}
template <class T1, class T2, class T3, class T4>
void PRINT2(tuple<T1, T2, T3, T4> t) {
    PRINT2(get<0>(t), get<1>(t), get<2>(t), get<3>(t));
}
template <class T1, class T2, class T3, class T4, class T5>
void PRINT2(tuple<T1, T2, T3, T4, T5> t) {
    PRINT2(get<0>(t), get<1>(t), get<2>(t), get<3>(t), get<4>(t));
}
template <class Head>
void PRINT2(vector<Head> head) {
    for (auto i = head.begin(); i != head.end(); i++) {
        PRINT2(*i);
        if (i != head.end() - 1) { cout << " "; }
    }
}
template <class Head>
void PRINT2(vector<vector<Head>> head) {
    for (auto i = head.begin(); i != head.end(); i++) {
        PRINT2(*i);
        if (i != head.end() - 1) { cout << endl; }
    }
}
template <size_t N, class Head>
void PRINT2(vector<array<Head, N>> head) {
    for (auto i = head.begin(); i != head.end(); i++) {
        PRINT2(*i);
        if (i != head.end() - 1) { cout << endl; }
    }
}
template <class... Head>
void PRINT2(vector<tuple<Head...>> head) {
    for (auto i = head.begin(); i != head.end(); i++) {
        PRINT2(*i);
        if (i != head.end() - 1) { cout << endl; }
    }
}
template <size_t N, class Head>
void PRINT2(array<Head, N> head) {
    for (auto i = head.begin(); i != head.end(); i++) {
        PRINT2(*i);
        if (i != head.end() - 1) { cout << " "; }
    }
}
template <class Head>
void PRINT2(Head head) {
    cout << head;
}
template <class Head, class... Tail>
void PRINT2(Head head, Tail... tail) {
    PRINT2(head);
    cout << " ";
    PRINT2((tail)...);
}
template <class Head>
void PRINT(Head head) {
    PRINT2(head);
    cout << endl;
}
template <class... Head>
void PRINT(Head... head) {
    PRINT2((head)...);
    cout << endl;
}
template <int N, class Head>
void PRINT(Head head) {
    PRINT2(head);
    cout << endl;
}
#pragma endregion Print
#pragma endregion Macro

ll calc_score(vector<int>& ans, vector<array<int, 26>>& S, array<int, 26>& C) {
    ll score = 0;
    array<int, 26> last;
    REP(i, 26) { last[i] = -1; }
    REP(d, 365) {
        int ct = ans[d];
        score += S[d][ct];
        last[ct] = d;
        REP(j, 26) { score -= C[j] * (d - last[j]); }
    }
    return score;
}
ll calc_score2(vector<int>& ans, vector<array<int, 26>>& S, array<int, 26>& C,
               ll score, int& ct_d, int& past_ct, int& new_ct) {
    score += S[ct_d][new_ct] - S[ct_d][past_ct];
    int last0 = -1;
    int last1 = -1;
    int cn = C[new_ct];
    int cp = C[past_ct];
    FOR(d, 0, 365) {
        if (ans[d] == new_ct) {
            last0 = d;
        } else if (ans[d] == past_ct) {
            last1 = d;
        }
        score -= cn * last0 + cp * last1;
    }
    ans[ct_d] = new_ct;
    last0 = -1;
    last1 = -1;
    FOR(d, 0, 365) {
        if (ans[d] == new_ct) {
            last0 = d;
        } else if (ans[d] == past_ct) {
            last1 = d;
        }
        score += cn * last0 + cp * last1;
    }
    return score;
}
ll calc_score3(vector<int>& ans, vector<array<int, 26>>& S, array<int, 26>& C,
               ll score, int& ct_d, int& ct_d2, int& past_ct, int& new_ct) {
    score += S[ct_d][new_ct] - S[ct_d][past_ct];
    score += S[ct_d2][past_ct] - S[ct_d2][new_ct];
    int last0 = -1;
    int last1 = -1;
    int cn = C[new_ct];
    int cp = C[past_ct];
    FOR(d, 0, 365) {
        if (ans[d] == new_ct) {
            last0 = d;
        } else if (ans[d] == past_ct) {
            last1 = d;
        }
        score -= cn * last0 + cp * last1;
    }
    ans[ct_d] = new_ct;
    ans[ct_d2] = past_ct;
    last0 = -1;
    last1 = -1;
    FOR(d, 0, 365) {
        if (ans[d] == new_ct) {
            last0 = d;
        } else if (ans[d] == past_ct) {
            last1 = d;
        }
        score += cn * last0 + cp * last1;
    }
    return score;
}
bool value(ll& new_score, ll& score, double& tp) {
    return exp((double)(new_score - score) / tp) > (double)rand() / RAND_MAX;
}
int main() {
    PRE_COMMAND
    int D, d, d2, new_ct, past_ct, ct_max, temp;
    double start_tp, end_tp, tp, delta;
    ll diff_max, diff, new_score, score_max;

    start_tp = 1300;
    end_tp = 440;
    ll MAX_cnt = 930000;

    array<int, 26> C, last;
    vector<array<int, 26>> S(365);
    vector<int> ans(365);
    vector<int> ans_max(365);
    cin >> D;
    for (int i = 0; i < 26; i++) { cin >> C[i]; }
    INPUT(S);
    REP(i, 26) { last[i] = -1; }
    REP(i, 365) {
        diff_max = -10000000000;
        ct_max = 0;
        REP(ct, 26) {
            diff = S[i][ct] + C[ct] * (i - last[ct]);
            temp = last[ct];
            last[ct] = i;
            FOR(j, i + 1, i + 4) {
                REP(ct2, 26) { diff -= C[ct2] * (j - last[ct2]); }
            }
            if (diff > diff_max) {
                ct_max = ct;
                diff_max = diff;
            }
            last[ct] = temp;
        }
        last[ct_max] = i;
        ans[i] = ct_max;
    }
    ll score = calc_score(ans, S, C);
    ll score_0 = score;
    score_max = score;
    ans_max = ans;
    tp = start_tp;
    delta = (double)(start_tp - end_tp) / MAX_cnt;
    REP(cnt, MAX_cnt) {
        // 一点更新
        d = rand() % 365;
        new_ct = rand() % 26;
        past_ct = ans[d];
        while (new_ct == past_ct) { new_ct = rand() % 26; }
        new_score = calc_score2(ans, S, C, score, d, past_ct, new_ct);
        if (value(new_score, score, tp)) {
            score = new_score;
        } else {
            ans[d] = past_ct;
        }
        if (score_max < score) {
            score_max = score;
            ans_max = ans;
        }
        // 2点スワップ
        d = rand() % 365;
        past_ct = ans[d];
        d2 = rand() % 365;
        new_ct = ans[d2];
        new_score = calc_score3(ans, S, C, score, d, d2, past_ct, new_ct);
        if (value(new_score, score, tp)) {
            score = new_score;
        } else {
            ans[d] = past_ct;
            ans[d2] = new_ct;
        }
        if (score_max < score) {
            score_max = score;
            ans_max = ans;
        }
        tp -= delta;
        // if (cnt % 10000 == 0) { PRINT(score, cnt); }
    }
    // cout << score_0 << " " << score_max << endl;
    REP(i, D) { cout << (ans[i] + 1) << endl; }
}


Measured memory_bytes: 4300