#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <climits>
#include <random>

constexpr int SINT_MAX = std::numeric_limits<int>::max();
constexpr int SINT_MIN = std::numeric_limits<int>::min();

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

template<class T>
T choose(bool b, T t, T f)
{
    if (b) return t;
    else return f;    
}

const char *YesNo(bool b)
{
    return choose(b, "Yes", "No");
}

const char *YESNO(bool b)
{
    return choose(b, "YES", "NO");
}

template<class NumT>
NumT diffabs(NumT l, NumT r)
{
    if (l < r) return r-l;
    else return l-r;    
}

struct myinout_t {} io;

template<class T>
myinout_t &operator >>(myinout_t &my, T &i)
{
    cin >> i;
    return my;
}

myinout_t &operator >>(myinout_t &my, int &i)
{
    int r = scanf("%d", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

myinout_t &operator >>(myinout_t &my, ll &i)
{
    int r = scanf("%lld", &i);
    if (r != 1) exit(EXIT_FAILURE);
    return my;
}

template<class T>
myinout_t &operator <<(myinout_t &my, const T &i)
{
    cout << i;
    return my;
}

myinout_t &operator <<(myinout_t &my, int i)
{
    printf("%d", i);
    return my;
}

myinout_t &operator <<(myinout_t &my, ll i)
{
    printf("%lld", i);
    return my;
}

constexpr char BR = '\n';


///////////////////////////////////////////////////

constexpr int CONTEST_SIZE = 26;
constexpr int DAY_MAXSIZE = 365;

int calc_score(int *r, const int c[CONTEST_SIZE], const int s[DAY_MAXSIZE][CONTEST_SIZE], int t[DAY_MAXSIZE], int D = DAY_MAXSIZE)
{
    int score = 0;
    int last[CONTEST_SIZE] = {};
    for (int d = 0; d < D; d++)
    {
        int con = t[d];
        score += s[d][con];
        last[con] = d+1;
        for (int i = 0; i < CONTEST_SIZE; i++)
        {
            score -= c[i] * (d+1 - last[i]);
        }
        if (r) r[d] = score;
    }
    return score;
}

int main()
{
    std::random_device seed_gen;
    mt19937 rnd(seed_gen());
    uniform_int_distribution dist(0, CONTEST_SIZE-1);

    int D; io >> D;
    int c[CONTEST_SIZE];
    int s[DAY_MAXSIZE][CONTEST_SIZE];
    for (int i = 0; i < CONTEST_SIZE; i++)
        io >> c[i];
    for (int d = 0; d < D; d++)
        for (int c = 0; c < CONTEST_SIZE; c++)
            io >> s[d][c];
    
    int t[DAY_MAXSIZE];

    for (int d = 0; d < D; d++)
    {
        int max_score = SINT_MIN;
        t[0] = 0;
        for (int i = 0; i < CONTEST_SIZE; i++)
        {
            int pre = t[d];
            t[d] = i;
            if (int cur_score = calc_score(nullptr, c, s, t, d+1); cur_score > max_score)
                max_score = cur_score;
            else
                t[d] = pre;
        }
    }

    int scores[DAY_MAXSIZE];
    int time_count = 10000;
    while (time_count--)
    {
        int cur_score = calc_score(scores, c, s, t ,D);
        int diff_score[DAY_MAXSIZE];
        diff_score[0] = scores[0];
        for (int d = 1; d < D; d++)
            diff_score[d] = scores[d] - scores[d-1];

        int min_d = rnd() % 365;
        int old = t[min_d];
        t[min_d] = rnd() % 26;
        if (int ss = calc_score(nullptr, c, s, t, D); ss > cur_score)
            cur_score = ss;
        else
            t[min_d] = old;
    }

#if DEBUG
    int score = calc_score(nullptr, c, s, t ,D);
    io << score << BR;
#else
    for (int d = 0; d < D; d++)
        io << (t[d] + 1) << BR;
#endif

}


Measured memory_bytes: 3824