#include <bits/stdc++.h>
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
int D;
int c[27], s[400][27];
int L[27];
int last[27];
long long ANS = 0;
long long ans = 0;
int T[400];
inline long long test(){
    for (int i = 1; i <= 26; i++){
        last[i] = 0;
    }
    long long ans = 0;
    for (int i = 1; i <= D; i++){
        ans += s[i][T[i]];
        last[T[i]] = i;
        for (int j = 1; j <= 26; j++){
            ans -= c[j]*(i-last[j]);
        }
    }
    return ans;
}
int t,x,y;
int ACTUAL[400];
double SCALE = 5000.0;
inline bool P(long long c1, long long c2, long long temp){
    bool ans = (c1>=c2)?1:exp(-temp*(c2-c1)/SCALE) >= rand()/32767.0;
    //printf("%lld -> %lld at temp %lld? %d\n",c2,c1,temp,ans);
    return ans;
}
long long ACTUALANS = 0;
long long totalscore = 0;
const int NUMTRIES = 1;
double testscale[] = {4900, 5000, 5100, 5200, 5300, 5400, 5500, 5600, 5700, 5800, 5900};
int main(){
    srand(time(NULL));
    D=365; ANS = 0;
    scanf("%d",&D);
    for (int i = 1; i <= 26; i++) {
        //c[i] = rand()%101;
        scanf("%d",&c[i]);
    }
    for (int i = 1; i <= D; i++){
        for (int j = 1; j <= 26; j++) {
            //s[i][j] = rand()%20001;
            scanf("%d",&s[i][j]);
        }
    }
    for (int i = 1; i <= NUMTRIES; i++){
        SCALE = testscale[i-1];
        //printf("Try %d/%d: ",i,NUMTRIES);
        auto begin_time=chrono::steady_clock::now().time_since_epoch().count();
        for (int i = 1; i <= 26; i++) L[i] = 0;
        for (int i = 1; i <= D; i++){
            int b1 = -1;
            long long ok = 0;
            for (t = 1; t <= 26; t++){
                for (x = 1; x <= 26; x++){
                    for (y = 1; y <= 26; y++){
                        ans = ANS;
                        int oldT = L[t], oldX = L[x], oldY = L[y];

                            ans += s[i][t];
                            L[t] = i;

                            for (int j = 1; j <= 26; j++){
                                ans -= c[j]*(i-L[j]);
                            }

                        if (i != D){
                            ans += s[i+1][x];
                            L[x] = i+1;
                            for (int j = 1; j <= 26; j++){
                                ans -= c[j]*(i+1-L[j]);
                            }
                        }

                        if (i < D-1){
                            ans += s[i+2][y];
                            L[y] = i+2;
                            for (int j = 1; j <= 26; j++){
                                ans -= c[j]*(i+2-L[j]);
                            }
                        }

                        if (b1 == -1 || ans > ok){
                            b1 = t;
                            ok = ans;
                        }
                        L[t] = oldT;
                        L[x] = oldX;
                        L[y] = oldY;
                    }
                }
                //printf("for %d: %lld\n",t,ans);
            }
            T[i] = b1;
            ANS += s[i][b1];
            L[b1] = i;
            for (int j = 1; j <= 26; j++){
                ANS -= c[j]*(i-L[j]);
            }
            //printf("%d\n",b1);
            //printf("score %lld\n",ANS);
        }
        long long best = ANS;
        //printf("before mutation %lld\n",best);
        //int curM = 0;
        //printf("from %lld\n",best);
        srand(time(NULL));
        int curT = 0;
        ACTUALANS = ANS;
        for (int i = 1; i <= D; i++) ACTUAL[i] = T[i];
        while (chrono::steady_clock::now().time_since_epoch().count()-begin_time<1985000000ll){
            curT++;
            int rD = rand()%365+1;
            int rV = rand()%26+1;
            int oldV = T[rD];
            T[rD] = rV;
            long long cur = test();
            if (P(cur,best,curT)){
                best = cur;

                //curM++;
                if (best > ACTUALANS){
                    ACTUALANS = best;
                    for (int i = 1; i <= D; i++){
                        ACTUAL[i] = T[i];
                    }
                    //printf("updating actual ans to %lld\n",best);
                }
                //printf("%lld\n",cur);
            }
            else{
                T[rD] = oldV;
            }
        }
        //printf("%f: %d mutations, %d actual, %lld, %lld\n",SCALE,curT,curM,best,ACTUALANS);
        for (int i = 1; i <= D; i++){
            printf("%d\n",ACTUAL[i]);
        }
        //printf("%lld\n",ACTUALANS);
        //totalscore += max(1000000+best,0ll);
        //printf("%lld\n",max(1000000+best,0ll));
    }
    //printf("%lld\n",totalscore/NUMTRIES*50);
}


Measured memory_bytes: 4244