#include <iostream>
#include <random>
#include <cstring>
#include <algorithm>

using namespace std;
struct Timer {
    static const unsigned long TICKS_PER_MSEC=3e6;
    unsigned long t1;
    Timer() { reset(); }
    unsigned long elapsed() { return gettime()-t1; }
    double elapsedMsec() { return 1.0*elapsed()/TICKS_PER_MSEC; }
    void reset() { t1=gettime(); }
    unsigned long gettime()
    {
        unsigned long lo, hi;
        asm volatile ("rdtsc" : "=a" (lo), "=d" (hi));
        return (hi<<32)|lo;
    }
};

int c[27], s[366][27], t[366], last[27][367], tlast[27][367];
int main()
{
    Timer timer;
    int D; cin>>D;
    for(int i=1; i<=26; ++i) cin>>c[i];
    for(int i=1; i<=D; ++i)
        for(int j=1; j<=26; ++j)
            cin>>s[i][j];

    auto calc_score=[&](){
        long score=0;
        memset(last, 0, sizeof(last));
        for(int d=1; d<=D; ++d) {
            score+=s[d][t[d]];
            last[t[d]][d]=d;
            for(int i=1; i<=26; ++i) {
                last[i][d+1]=last[i][d];
                score-=c[i]*(d-last[i][d]);
            }
        }
        return score;
    };
    // t[i]=q
    auto calc_diff_change=[&](int i, int q) {
        long ds=0;
        int p=t[i];
        ds-=s[i][p];
        ds+=s[i][q];
        for(int d=i; d<=D; ++d) {
            ds+=c[p]*(d-tlast[p][d]);
            ds+=c[q]*(d-tlast[q][d]);
        }
        tlast[p][i]=tlast[p][i-1];
        for(int d=i+1; d<=D; ++d) {
            if (t[d]==p) break;
            tlast[p][d]=tlast[p][d-1];
        }
        tlast[q][i]=i;
        for(int d=i+1; d<=D; ++d) {
            if (t[d]==q) break;
            tlast[q][d]=tlast[q][d-1];
        }
        for(int d=i; d<=D; ++d) {
            ds-=c[p]*(d-tlast[p][d]);
            ds-=c[q]*(d-tlast[q][d]);
        }
        return ds;
    };
    // swap(t[i], t[j])
    auto calc_diff_swap=[&](int i, int j) {
        int p=t[i], q=t[j];
        return calc_diff_change(i, q) + calc_diff_change(j, p);
    };

    for(int i=1; i<=D; ++i) {
        long bestscore=-(1L<<60), typ=1;
        for(int j=1; j<=26; ++j) {
            t[i]=j;
            auto score=calc_score();
            t[i]=0;
            if (bestscore<score) {
                bestscore=score;
                typ=j;
            }
        }
        t[i]=typ;
    }

    mt19937 engine;
    uniform_int_distribution<> rndT(1, 26), rndD(1, 365), rndR(0, 1);
    normal_distribution<> rndS(0.0, 182.0);
    auto bestscore=calc_score();

    int cnt=0;
    while (timer.elapsedMsec()<1950) {
        if (!rndR(engine)) {
            int d=rndD(engine);
            int q=rndT(engine);
            int p=t[d];
            memcpy(tlast[p], last[p], sizeof(last[p]));
            memcpy(tlast[q], last[q], sizeof(last[q]));
            auto dscore=calc_diff_change(d, q);
            if (dscore>0) {
                bestscore+=dscore;
                t[d]=q;
                memcpy(last[p], tlast[p], sizeof(last[p]));
                memcpy(last[q], tlast[q], sizeof(last[q]));
            }
            /*
            auto score=calc_score();
            if (bestscore<score) {
                t[d]=q;
                bestscore=score;
            }
            */
        }
        else {
            int a=rndD(engine);
            //int b=rndD(engine);
            int b=clamp((double)rndS(engine)+a, 1., 365.);
            int p=t[a], q=t[b];
            memcpy(tlast[p], last[p], sizeof(last[p]));
            memcpy(tlast[q], last[q], sizeof(last[q]));
            auto dscore=calc_diff_swap(a, b);
            if (dscore>0) {
                bestscore+=dscore;
                swap(t[a], t[b]);
                memcpy(last[p], tlast[p], sizeof(last[p]));
                memcpy(last[q], tlast[q], sizeof(last[q]));
            }
            /*
            auto score=calc_score();
            if (bestscore<score) {
                swap(t[a], t[b]);
                bestscore=score;
            }
            */
        }
        ++cnt;
    }
    for(int i=1; i<=D; ++i) cout<<t[i]<<endl;
    //cout<<bestscore<<", "<<cnt<<endl;
}


Measured memory_bytes: 4116