#include <algorithm>
#include <chrono>
#include <iostream>
#include <random>
#include <vector>

using namespace std;

constexpr int d = 365;
constexpr int t = 26;
constexpr double rest_time = 1950;

int64_t evaluate_line(
    const vector<int64_t>& cs, const vector<vector<int64_t>>& ss, const vector<int>& state, const int j)
{
    int last = -1;
    int64_t sum = 0;
    for (int i = 0; i < d; i++)
    {
        sum += ss[i][state[i]];
        if (state[i] == j)
        {
            last = i;
        }
        sum -= cs[j] * (i - last);
    }
    return sum;
}

int64_t evaluate(const vector<int64_t>& cs, const vector<vector<int64_t>>& ss, const vector<int>& state)
{
    int64_t sum = 0;

    for (int j = 0; j < t; j++)
    {
        sum += evaluate_line(cs, ss, state, j);
    }
    return sum;
}

void solve(const vector<int64_t>& cs, const vector<vector<int64_t>>& ss, vector<int>& state, mt19937_64& mt)
{
    const auto start = chrono::system_clock::now();

    uniform_int_distribution<int> day_rand(0, d - 1);
    uniform_real_distribution<double> prob_rand;

    vector<int> accum_cs(t + 1, 0);
    for (int i = 0; i < t; i++)
    {
        accum_cs[i + 1] = cs[i];
        accum_cs[i + 1] += accum_cs[i];
    }
    uniform_int_distribution<int> weighted_type_rand(0, accum_cs[t] - 1);

    vector<int> best_state(d);

    vector<int64_t> eval_line(t, 0);
    for (int j = 0; j < t; j++)
    {
        eval_line[j] = evaluate_line(cs, ss, state, j);
    }

    auto eval = evaluate(cs, ss, state);
    auto best_eval = eval;

    double rate = 1.0;

    int counter = 0;
    while (true)
    {
        const int change_pos = day_rand(mt);
        const int r = weighted_type_rand(mt);
        int to_type = 0;
        for (int i = 0; i < t; i++)
        {
            if (accum_cs[i] <= r && r < accum_cs[i + 1])
            {
                to_type = i;
            }
        }
        if (state[change_pos] == to_type)
        {
            continue;
        }

        const auto from_type = state[change_pos];
        state[change_pos] = to_type;

        const auto eval_line_from = evaluate_line(cs, ss, state, from_type);
        const auto eval_line_to = evaluate_line(cs, ss, state, to_type);

        const auto eval_diff = (eval_line_from + eval_line_to) - (eval_line[from_type] + eval_line[to_type]);

        if (eval_diff > 0 || exp(eval_diff * rate * 0.15) > prob_rand(mt))
        {
            eval += eval_diff;
            eval_line[from_type] = eval_line_from;
            eval_line[to_type] = eval_line_to;
        }
        else
        {
            state[change_pos] = from_type;
        }

        if (counter++ % 1000 == 0)
        {
            const auto end = chrono::system_clock::now();
            const auto duration = chrono::duration_cast<chrono::milliseconds>(end - start).count();
            if (duration > rest_time)
            {
                break;
            }
            rate = (rest_time - duration) / rest_time;
        }
        if (best_eval < eval)
        {
            best_eval = eval;
            copy(state.begin(), state.end(), best_state.begin());
        }
    }
    copy(best_state.begin(), best_state.end(), state.begin());
}

int main()
{
    {
        int _;
        cin >> _;
    }

    vector<int64_t> cs(t);
    for (auto& c : cs)
    {
        cin >> c;
    }
    vector<vector<int64_t>> ss(d, vector<int64_t>(t));
    for (auto& row : ss)
    {
        for (auto& e : row)
        {
            cin >> e;
        }
    }

    mt19937_64 mt(0);
    uniform_int_distribution<int> rand(0, t - 1);

    vector<int> state(d);
    for (int i = 0; i < d; i++)
    {
        state[i] = rand(mt);
    }

    solve(cs, ss, state, mt);

    for (int i = 0; i < d; i++)
    {
        cout << (state[i] + 1) << endl;
    }
}

Measured memory_bytes: 3932