#include <bits/stdc++.h>

int main()
{
    const auto start = std::chrono::system_clock::now();
    const auto time_limit = start + std::chrono::milliseconds(1800);

    std::size_t D;
    std::cin >> D;
    std::array<std::uint16_t, 26> Cs;
    for(auto& c : Cs)
    {
        std::cin >> c;
    }

    std::vector<std::array<std::uint16_t, 26>> ss(D);
    for(std::size_t i=0; i<D; ++i)
    {
        for(std::size_t c=0; c<26; ++c)
        {
            std::cin >> ss[i][c];
        }
    }

    std::array<std::uint16_t, 26> last_day;
    last_day.fill(0);

    const auto calc_score = [&](const std::size_t day, const std::size_t held) {
        std::int32_t score = ss[day-1][held];
        for(std::size_t c=0; c<26; ++c)
        {
            if(c == held) {continue;}
            score -= Cs[c] * (day - last_day[c]);
        }
        return score;
    };

    std::vector<std::size_t> best_solution(D);
    std::vector<std::size_t> current_solution(D);
    std::vector<std::size_t> tmp_solution(D);
    std::int32_t current_score = 0;
    std::int32_t best_score    = 0;

    for(std::size_t day=1; day<=D; ++day)
    {
        std::uint16_t contest = 65535;
        std::int32_t  s_diff  = std::numeric_limits<std::int32_t>::min();
        for(std::size_t c=0; c<26; ++c)
        {
            const auto delta = calc_score(day, c);
            if(s_diff < delta)
            {
                s_diff  = delta;
                contest = c;
            }
        }
        last_day[contest] = day;
        current_solution[day-1] = contest + 1;
        current_score += s_diff;
    }
    best_solution = current_solution;
    best_score = current_score;

//     std::cerr << "start from " << best_score << std::endl;
//     for(const auto s : best_solution)
//     {
//         std::cout << s << std::endl;
//     }

    std::mt19937 mt(123456789);
    std::bernoulli_distribution ber(1.0 / 200.0);
    std::uniform_int_distribution<std::size_t> uni(0, 25);
    std::uniform_real_distribution<double> unir(0.0, 1.0);

    while(std::chrono::system_clock::now() < time_limit)
    {
        last_day.fill(0);

        std::int32_t next_score = 0;
        for(std::size_t day=1; day<=D; ++day)
        {
            const auto contest = ber(mt) ? uni(mt) : current_solution[day-1]-1;

            next_score += calc_score(day, contest);
            last_day[contest] = day;
            tmp_solution[day-1] = contest + 1;
        }

        const auto diff = next_score - current_score;
        if(0 <= diff || unir(mt) < std::exp(diff * 0.01))
        {
            current_score    = next_score;
            current_solution = tmp_solution;
        }
        if(best_score < next_score)
        {
            best_score    = next_score;
            best_solution = tmp_solution;
        }
    }

//     std::int32_t score = 0;
//     std::int32_t day = 1;
//     last_day.fill(0);
    for(const auto s : best_solution)
    {
        std::cout << s << std::endl;
//         score += calc_score(day, s-1);
//         last_day[s-1] = day;
//         day += 1;
    }
//     std::cerr << best_score << std::endl;
//     std::cerr << score << std::endl;
    return 0;
}


Measured memory_bytes: 4368