#include <vector>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <chrono>
#include <cstdio>
#include <iostream>
using namespace std;

unsigned int xor128() {
    static unsigned int x=123456789, y=362436069, z=521288629, w=88675123;
    unsigned int t;
    t=(x^(x<<11)); x=y; y=z; z=w;
    return (w=(w^(w>>19))^(t^(t>>8)));
}

inline bool rand_bool(double prob) {
    constexpr double x = 1LL<<32; // uint_max+1
    return xor128() < prob * x;
}

int timelimit = 2 * 1000, elapsed = 0, margin = 20;

class Timer {
  chrono::system_clock::time_point start_time = chrono::system_clock::now();
public:
  Timer() {}
  int get_elapsed_time() {
    auto diff = chrono::system_clock::now() - start_time;
    return chrono::duration_cast<chrono::milliseconds>(diff).count();
  }
} timer;


const int D = 365;
int c[26], s[D][26];

int greedy(int *ans) {
    int score = 0;
    int last[26] = {};
    fill(last, last+26, -1);
    for (int d = 0; d < D; d++) {
        int max_inc = -(1<<30);
        int best_type = -1;
        for (int i = 0; i < 26; i++) {
            int inc = s[d][i];
            for (int j = 0; j < 26; j++)
                if (j != i) inc -= c[j] * (d - last[j]);
            if (max_inc < inc) {
                max_inc = inc;
                best_type = i;
            }
        }
        ans[d] = best_type;
        last[best_type] = d;
        score += max_inc;
    }
    return score;
}

int csum[26], C;

inline int choose_type() {
    return xor128() % 26;
    // int i = xor128()%C;
    // int j = lower_bound(csum, csum+26, i) - csum;
    // return j;
}

inline int T(int x) { return x * (x - 1) / 2; }

int mutate(int *ans, int d, int i) {
    int diff = 0;
    int save = ans[d];
    ans[d] = i;
    diff += s[d][i] - s[d][save];

    int dp = -1, dn = D;
    for (int x = d-1; x >= 0; x--)
        if (ans[x] == i) { dp = x; break; }
    for (int x = d+1; x < D; x++)
        if (ans[x] == i) { dn = x; break; }
    diff -= c[i] * (T(dn - d) + T(d - dp) - T(dn - dp));

    dp = -1, dn = D;
    for (int x = d-1; x >= 0; x--)
        if (ans[x] == save) { dp = x; break; }
    for (int x = d+1; x < D; x++)
        if (ans[x] == save) { dn = x; break; }
    diff += c[save] * (T(dn - d) + T(d - dp) - T(dn - dp));

    return diff;
}

int main(int argc, char **argv) {
    if (argc > 1) timelimit = atoi(argv[1]) * 1000;
    scanf("%*d");
    for (int i = 0; i < 26; i++) cin >> c[i];
    for (int i = 0; i < 26; i++) csum[i] = c[i] + (i > 0 ? csum[i-1] : 0) + 10;
    C = csum[25];
    for (int d = 0; d < D; d++)
        for (int i = 0; i < 26; i++) cin >> s[d][i];

    int ans[D];
    int score = greedy(ans);
    int iter = 0;
    int best_ans[D], best_score = score;
    copy(ans, ans+D, best_ans);
    const double start_temp = 1500;
    double temp = start_temp;
    int elapsed = timer.get_elapsed_time();
    int wmax = 20;
    vector<pair<int, int> > rollback_info;
    while (elapsed + margin < timelimit) {
        if ((iter & ((1<<16) - 1)) == 0) {
            elapsed = timer.get_elapsed_time();
            double r = 1 - double(elapsed) / timelimit;
            temp = r * start_temp;
            wmax = max(int(20 * r), 2);
        }
        rollback_info.clear();
        int diff = 0;
        if (rand_bool(0.2)) {
            int d = xor128()%D;
            int i = choose_type();
            rollback_info.push_back({d, ans[d]});
            diff += mutate(ans, d, i);
        } else {
            int w = xor128()%wmax + 1;
            int d1 = xor128()%(D-w), d2 = d1 + w;
            const int i1 = ans[d1], i2 = ans[d2];
            rollback_info.push_back({d1, i1});
            rollback_info.push_back({d2, i2});
            diff += mutate(ans, d1, i2);
            diff += mutate(ans, d2, i1);
        }

        const int tmp_score = score + diff;
        bool update = diff >= 0;
        if (!update && diff > -10 * temp) {
            const double prob = exp(diff / temp);
            update = rand_bool(prob);
        }
        if (best_score < tmp_score) {
            // cerr << iter << ' ' << best_score << " " << score << ' ' << rollback_info.size() << endl;
            best_score = tmp_score;
            copy(ans, ans+D, best_ans);
        }
        if (update) {
            score = tmp_score;
        } else {
            for (auto &[d, i] : rollback_info) ans[d] = i;
        }
        iter++;
    }
    cerr << iter << ' ' << best_score << endl;

    for (int d = 0; d < D; d++) cout << best_ans[d] + 1 << endl;
}


Measured memory_bytes: 3920