#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(const vector<int64_t>& cs, const vector<vector<int64_t>>& ss, vector<int>& state)
{
    int64_t sum = 0;

    vector<int> last(t, -1);

    for (int i = 0; i < d; i++)
    {
        sum += ss[i][state[i]];
        last[state[i]] = i;

        for (int j = 0; j < t; j++)
        {
            sum -= cs[j] * (i - last[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_int_distribution<int> type_rand(0, t - 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);

    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 after_eval = evaluate(cs, ss, state);

        if (eval < after_eval || exp(-(eval - after_eval) * rate) > prob_rand(mt))
        {
            eval = after_eval;
        }
        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());
    std::cerr << counter << std::endl;
}

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: 3872