#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

struct timer {
    std::chrono::system_clock::time_point start, end;

    timer() {
        start = std::chrono::system_clock::now();
    }

    double get() {
        end = std::chrono::system_clock::now();
        return std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
    }
};

int D;
int c[26], s[365][26], t[365], last[26], ans[366];

void calc() {
    for (int i = 0; i < D; ++i) {
        ans[i + 1] = ans[i] + s[i][t[i]];
        last[t[i]] = i + 1;
        for (int j = 0; j < 26; ++j)
            ans[i + 1] -= c[j] * (i + 1 < last[j] ? i + 1 : i + 1 - last[j]);
    }
}

void change(int d, int q) {
    int old = t[d];
    if (old == q)
        return;

    t[d] = q, last[old] = 0, last[q] = 0;
    int dif = 0, pos1 = 0, pos2 = 0;
    for (int i = 0; i < D; ++i) {
        last[t[i]] = i + 1;
        if (i < d)
            pos1 = last[q], pos2 = last[old];
        else {
            ans[i + 1] += s[d][q] - s[d][old];
            if (last[q] == d + 1)
                dif += c[q] * (d + 1 - pos1);
            if (last[old] <= d + 1)
                dif -= c[old] * (d + 1 - pos2);
        }
        ans[i + 1] += dif;
    }
}

void greedy() {
    for (int i = 0; i < D - 1; ++i) {
        ans[i + 2] = INT_MIN;
        int maidx1 = 0, maidx2 = 0;
        for (int k1 = 0; k1 < 26; ++k1) {
            int old1 = last[k1];
            for (int k2 = 0; k2 < 26; ++k2) {
                int res = ans[i] + s[i][k1] + s[i + 1][k2], res1;
                int old2 = last[k2];
                last[k1] = i + 1;
                for (int j = 0; j < 26; ++j)
                    res -= c[j] * (i + 1 - last[j]);
                res1 = res;
                last[k2] = i + 2;
                for (int j = 0; j < 26; ++j)
                    res -= c[j] * (i + 2 - last[j]);

                if (ans[i + 2] < res) {
                    ans[i + 2] = res;
                    ans[i + 1] = res1 - s[i + 1][k2];
                    maidx1 = k1;
                    maidx2 = k2;
                }
                last[k2] = old2;
            }
            last[k1] = old1;
        }
        t[i] = maidx1;
        last[t[i]] = i + 1;
        if (i + 1 == D - 1) {
            t[i + 1] = maidx2;
            last[t[i + 1]] = i + 2;
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> D;
    for (int i = 0; i < 26; ++i)
        cin >> c[i];
    for (int i = 0; i < D; ++i)
        for (int j = 0; j < 26; ++j)
            cin >> s[i][j];

    greedy();
    std::mt19937_64 gen(0);
    std::uniform_int_distribution<> dist1(1, D);
    std::uniform_int_distribution<> dist2(1, 26);

    timer tm;
    while (tm.get() < 1500) {
        stack<pii> stk;
        int pres = ans[D];
        for (int j = 0; j < 50; ++j) {
            int d = dist1(gen), q = dist2(gen);
            d--, q--;
            stk.emplace(pii{d, t[d]});
            change(d, q);
            if (ans[D] >= pres)
                break;
        }
        if (ans[D] < pres) {
            while (!stk.empty()) {
                auto [d, q] = stk.top();
                change(d, q);
                stk.pop();
            }
        }
    }
    for (int i = 0; i < D; ++i)
        cout << t[i] + 1 << '\n';

    return 0;
}


Measured memory_bytes: 3724