#include <bits/stdc++.h>
#include <time.h>
#pragma GCC optimize("O3")
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

//var define
int d,initscore=0;
vector<int>c(26);
vector<int>t(365,0);
vector<vector<int>>s(365,vector<int>(26));
vector<int>last(26,0);

unsigned int randxor()
{
    static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned int t;
    t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

vector<vector<int>>loss(26,vector<int>());
int getScore(vector<int>&t){
      int score=0;
      vector<int>lastt(26,0);
      for (int i = 0; i < d; i++)
   {
       int x=t[i];
       lastt[x]=i+1;
       for (int j = 0; j < 26; j++)
       {
           score-=(i+1 - lastt[j])*c[j];
       }
       score+=s[i][x];
   }
   return score;
}

int tt;
vector<int>best(365,0);
int bestScore=-INF;
vector<int> yakinamashi(double msec,int nowscore)
{
    for (int i = 0; i < d; i++)
    {
        best[i]=t[i];
    }
    bestScore=getScore(t);
    int currentScore = bestScore;
    double saTimeStart = (double)clock() / CLOCKS_PER_SEC;
    double saTimeCurrent = saTimeStart;
    double saTimeEnd = saTimeStart + msec;
    int start_temp = 500, end_temp = 5;
    double TIME;

    while ((saTimeCurrent = (double)clock() / CLOCKS_PER_SEC) < saTimeEnd)
    {
        //cerr << (double)clock()/CLOCKS_PER_SEC << endl;
        double T = saTimeCurrent - saTimeStart;
        double temp = T;
        for (int loop = 0; loop < 50; loop++)
        {
            tt++;
            
            int index1;
            int index2,tmp;
            int idx,num,tmp2;
            bool check=true;
            int c=randxor();
             if(c%3!=0 ){
             index1 = randxor() % d;
             index2 = randxor() % d;
             tmp = t[index2];
            //swich
            t[index2] = t[index1];
            t[index1] = tmp;
             }
            else{
                check=false;
                idx=randxor()%d;
                num=randxor()%26;
                tmp2=t[idx];
                t[idx]=num;
            }
            
            // int nextScore = currentScore - tmp_score + getScore2(index1, index2);
            //int nextScore = getScore1(index1,index2,currentScore);
            int nextScore=getScore(t);
            double TT = saTimeEnd - saTimeStart;
            
            //  int R = 10000;
            temp *= 0.99;
            TIME = static_cast<double>(saTimeEnd - saTimeStart);

            double prob = exp((double)(nextScore - currentScore)/temp );
            //bool FORCE_NEXT = R * (T - t) > T * (randxor() % R);
            //  次に遷移
            //cerr<<prob<<endl;
            if (nextScore > currentScore || (prob > (randxor() % (unsigned ll)(1e18) / (double)(1e18))))
            {
                currentScore = nextScore;
                //printf("New best Score=%d time=%lf\n", bestScore, t);
            }
            //遷移しない時は戻す
            else
            {
                if(check){
                t[index1] = t[index2];
                t[index2] = tmp;
                }
                else{
                    t[idx]=tmp2;
                }
            }

            //bestScore
            if (currentScore > bestScore)
            {
                bestScore = currentScore;
                for (int i = 0; i < d; i++)
                {

                    best[i] = t[i];
                }
             //cerr<<bestScore<<endl;
            }
        }
    }
    return best;
}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>d;
  
    for (int i = 0; i < 26; i++)
    {
        cin>>c[i];
    }

    for (int i = 0; i < d; i++)
    {
        for (int j = 0; j < 26; j++)
        {
            cin >> s[i][j];
        }
    }
    vector<int>prelast(26,0);
    int cur=0;
    for (int i = 0; i < d; i++)
    {
        int pre=-INF;
        int id;
        for (int j = 0; j < 26; j++)
        {
            int tmp=cur;
            int x=j;
            int fin=i+1;

            for (int k = 0; k < 26; k++)
            {
                if(k==j){
                    continue;
                }
                tmp-=(i+1 - prelast[k])*c[k];
            }
            tmp+=s[i][x];
            if(pre<tmp){
                pre = tmp;
                id = j;
            }
        }
       // cerr<<cur<<endl;
        prelast[id]=i+1;
        t[i]=id;
        cur = pre;
        //cerr<<cur<<endl;
    }
    
   initscore=cur;
    vector<int>ans=yakinamashi(1.97,initscore);
    for (int i = 0; i < d; i++)
    {
        cout<<best[i]+1<<endl;
    }

  
    
    
    return 0;
}

Measured memory_bytes: 4324