#include <bits/stdc++.h>

#include <utility>

using namespace std;

class xor_shift_128 {
public:
    typedef uint32_t result_type;
    explicit xor_shift_128(uint32_t seed = 42) {
        set_seed(seed);
    }
    void set_seed(uint32_t seed) {
        a = seed = 1812433253u * (seed ^ (seed >> 30));
        b = seed = 1812433253u * (seed ^ (seed >> 30)) + 1;
        c = seed = 1812433253u * (seed ^ (seed >> 30)) + 2;
        d = seed = 1812433253u * (seed ^ (seed >> 30)) + 3;
    }
    uint32_t operator() () {
        uint32_t t = (a ^ (a << 11));
        a = b; b = c; c = d;
        return d = (d ^ (d >> 19)) ^ (t ^ (t >> 8));
    }
    static constexpr uint32_t max() { return numeric_limits<result_type>::max(); }
    static constexpr uint32_t min() { return numeric_limits<result_type>::min(); }
private:
    uint32_t a{}, b{}, c{}, d{};
};

const int CONTEST_NUM = 26;

struct Input {
    vector<int> costs;
    vector<vector<int>> values;
    int day_num;
    explicit Input (vector<int> costs, vector<vector<int>> values, int day_num) : costs(move(costs)), values(move(values)), day_num(day_num) {}
};

struct State {
    vector<int> contest_order;
    vector<set<int>> date_per_contest;
    shared_ptr<Input> input;
    long long score = 0;
    explicit State(shared_ptr<Input> input) : contest_order(vector<int>(input->day_num+1)), date_per_contest(vector<set<int>>(CONTEST_NUM+1)), input(input) {}
    State() = default;

    void compute_score() {
        vector<int> last(CONTEST_NUM+1, 0);
        for (int i=1; i<=input->day_num; i++) {
            score += input->values[i][contest_order[i]];
            last[contest_order[i]] = i;
            for (int j=1; j<=CONTEST_NUM; j++) {
                score -= input->costs[j] * (i - last[j]);
            }
        }
    }

    long long compute_diff(const int date, const int newContestId) {
        int oldContestPreviousDate = 0, oldContestNextDate = input->day_num+1, newContestPreviousDate = 0, newContestNextDate = input->day_num+1;
        const int oldContestId = contest_order[date];
        auto itr = date_per_contest[oldContestId].lower_bound(date);
        if (itr != date_per_contest[oldContestId].begin()) {
            itr--;
            oldContestPreviousDate = *itr;
            itr++;
        }
        if (itr != date_per_contest[oldContestId].end()) {
            itr++;
            if (itr != date_per_contest[oldContestId].end()) {
                oldContestNextDate = *itr;
            }
            itr--;
        }
        itr = date_per_contest[newContestId].lower_bound(date);
        if (itr != date_per_contest[newContestId].begin()) {
            itr--;
            newContestPreviousDate = *itr;
            itr++;
        }
        if (itr != date_per_contest[newContestId].end()) {
            newContestNextDate = *itr;
        }

        long long diff = 0;
        int t0 = date - oldContestPreviousDate, n = oldContestNextDate - date;
        diff -= input->costs[oldContestId] * (n * (n+1)/2 + (t0 - 1) * n);
        t0 = date - newContestPreviousDate, n = newContestNextDate - date;
        diff += input->costs[newContestId] * (n * (n+1)/2 + (t0 - 1) * n);
        diff -= input->values[date][oldContestId];
        diff += input->values[date][newContestId];

        return diff;
    }

    void update(const int date, const int newContestId) {
        const int oldContestId = contest_order[date];

        score += compute_diff(date, newContestId);

        date_per_contest[oldContestId].erase(date);
        date_per_contest[newContestId].insert(date);

        contest_order[date] = newContestId;
    }
};

template <class Generator>
int choose(int const min, int const max, Generator & gen) {
    assert (min <= max);
    return uniform_int_distribution<int>(min, max)(gen);
}

template <class Generator>
State solve(const shared_ptr<Input>& input, Generator & gen) {
    State best_state, state(input);

    if (getenv("RESUME")) {
        ifstream ifs(getenv("RESUME"));
        string line;
        getline(ifs, line);
        int cnt = 0;
        while (getline(ifs, line)) {
            cnt++;
            if (cnt % 2 == 0) continue;
            stringstream ss_line(line);
        }
    } else {  // make an initial state
        vector<int> last(CONTEST_NUM+1, 0);
        for (int i=1; i<=input->day_num; i++) {
            long long max_diff = LLONG_MIN, contest_id = -1;
            for(int j=1; j<=CONTEST_NUM; j++) {
                long long diff = input->values[i][j];
                for(int k=1; k<=CONTEST_NUM; k++) {
                    if (k==j) continue;
                    diff -= input->costs[k] * (i - last[k]);
                }
                if (diff > max_diff) {
                    max_diff = diff;
                    contest_id = j;
                }
            }
            assert(contest_id != -1);
            state.contest_order[i] = contest_id;
            last[state.contest_order[i]] = i;
            state.date_per_contest[contest_id].insert(i);
        }
    }

    state.compute_score();
    best_state = state;
    long long highscore = state.score;
    cerr << "[*] highscore = " << highscore << endl;

    constexpr int TIME_LIMIT = 1900;  // msec
    constexpr int TEMPERATURE_FIRST = 2000;
    constexpr int TEMPERATURE_LAST = 600;
    chrono::high_resolution_clock::time_point clock_begin = chrono::high_resolution_clock::now();
    double temperature = 1;
    for (unsigned iteration = 0; ; ++ iteration) {
        if (iteration % 128 == 0) {
            chrono::high_resolution_clock::time_point clock_end = chrono::high_resolution_clock::now();
            const double t = 1.0 * chrono::duration_cast<chrono::milliseconds>(clock_end - clock_begin).count() / TIME_LIMIT;
            temperature = std::pow(TEMPERATURE_FIRST, 1.0 - t) * std::pow(TEMPERATURE_LAST, t);
            if (t >= 1) {
                cerr << "[*] iteration = " << iteration << ": done" << endl;
                break;
            }
        }

        long long delta = LLONG_MIN, old_score = state.score;

        if (bernoulli_distribution(0.5)(gen)) {
            const int day = choose(1, input->day_num, gen);
            int new_contest_id = -1;
            for (int i=1; i<=CONTEST_NUM; i++) {
                long long diff = state.compute_diff(day, i);
                if (delta < diff) {
                    delta = diff;
                    new_contest_id = i;
                }
            }
            if (delta >= 0 or bernoulli_distribution(exp((double)delta / temperature))(gen)) {
                if (delta < 0) {
                    cerr << "[*] iteration = " << iteration << ": delta = " << delta << ": p = " << exp((double)delta / temperature) << endl;
                }
                state.update(day, new_contest_id);
            }
        } else {
            const int day1 = choose(1, input->day_num-1, gen);
            const int day2 = choose(day1+1, min(input->day_num,day1+16), gen);
            const int day1_new_contest_id = state.contest_order[day2];
            const int day2_new_contest_id = state.contest_order[day1];
            delta = state.compute_diff(day1, day1_new_contest_id) + state.compute_diff(day2, day2_new_contest_id);
            if (delta >= 0 or bernoulli_distribution(exp((double)delta / temperature))(gen)) {
                if (delta < 0) {
                    cerr << "[*] iteration = " << iteration << ": delta = " << delta << ": p = " << exp((double)delta / temperature) << endl;
                }
                state.update(day1, day1_new_contest_id);
                state.update(day2, day2_new_contest_id);
            }
        }
        if (highscore < state.score) {
            highscore = state.score;
            best_state = state;
            cerr << "[*] iteration = " << iteration << ": highscore = " << highscore << endl;
        }
    }

    cerr << "[*] highscore = " << highscore << endl;

    return best_state;
}

int main() {
    int D;
    cin >> D;
    std::vector<int> c(CONTEST_NUM+1);
    for(int i = 1 ; i <= CONTEST_NUM ; i++){
        cin >> c[i];
    }
    std::vector<std::vector<int>> s(D+1, std::vector<int>(CONTEST_NUM+1));
    for(int i = 1 ; i <= D ; i++){
        for(int j = 1 ; j <= 26 ; j++){
            cin >> s[i][j];
        }
    }
    Input* input = new Input(c, s, D);
    shared_ptr<Input> input_ptr(input);

    // solve
    xor_shift_128 gen;
    State state = solve(input_ptr, gen);

    // output
    stringstream ss;
    for (int i=1; i<=D; i++) {
        ss << state.contest_order[i] << "\n";
    }
    cout << ss.str();
    return 0;
}


Measured memory_bytes: 4576