#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 new_contest_id) {
        int old_contest_previous_date = 0,
            old_contest_next_date = input->day_num + 1,
            new_contest_previous_date = 0,
            new_contest_next_date = input->day_num + 1;
        const int old_contest_id = contest_order[date];
        if (new_contest_id == old_contest_id) {
            return 0;
        }
        auto itr = date_per_contest[old_contest_id].lower_bound(date);
        if (itr != date_per_contest[old_contest_id].begin()) {
            itr--;
            old_contest_previous_date = *itr;
            itr++;
        }
        if (itr != date_per_contest[old_contest_id].end()) {
            itr++;
            if (itr != date_per_contest[old_contest_id].end()) {
                old_contest_next_date = *itr;
            }
            itr--;
        }
        if (!date_per_contest[new_contest_id].empty()) {
            itr = date_per_contest[new_contest_id].lower_bound(date);
            if (itr != date_per_contest[new_contest_id].begin()) {
                itr--;
                new_contest_previous_date = *itr;
                itr++;
            }
            if (itr != date_per_contest[new_contest_id].end()) {
                new_contest_next_date = *itr;
            }
        }

        long long diff = 0;
        long long t0 = date - old_contest_previous_date, n = old_contest_next_date - date;
        diff -= input->costs[old_contest_id] * n * t0;
        t0 = date - new_contest_previous_date, n = new_contest_next_date - date;
        diff += input->costs[new_contest_id] * n * t0;
        diff -= input->values[date][old_contest_id];
        diff += input->values[date][new_contest_id];

        return diff;
    }

    void update(const int date, const int new_contest_id) {
        const int old_contest_id = contest_order[date];

        score += compute_diff(date, new_contest_id);

        date_per_contest[old_contest_id].erase(date);
        date_per_contest[new_contest_id].insert(date);

        contest_order[date] = new_contest_id;
    }
};

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 old_score = state.score;

        if (bernoulli_distribution(0.5)(gen)) {
            // random
            const int day = choose(1, input->day_num, gen);
            const int new_contest_id = choose(1, CONTEST_NUM, gen);
            long long delta = state.compute_diff(day, 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(day, new_contest_id);
                assert(state.score == old_score + delta);
            }
        } else {
            // swap
            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];
            state.update(day1, day1_new_contest_id);
            state.update(day2, day2_new_contest_id);
            long long delta = state.score - old_score;
            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;
                }
            } else {
                state.update(day1, day2_new_contest_id);
                state.update(day2, day1_new_contest_id);
                assert(state.score == old_score);
            }
        }
        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: 4600