#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>
#include <random>
using namespace std;

#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
//#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
#define rep(i,a,n) for(Int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(Int (i)=(a); (i)<=(n); (i)++)
const int MAX_N = 1000000;
const Int MAX_N_Int = 1000000000000;

template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}

int D;
string str,s,u;
vector<int>c(26);
vector<int>t(366);
vector<pair<int,int>> v(26);

vector<vector<int>> ss(366, vector<int>(26));
//vector<vector<int>> last(365, vector<int>(26));
vector<int> last(26),last0(26);
int satisfaction=0;
int init_score;

int init(){
    vector<int>c_copy(26);
    c_copy=c;
    rsort(c_copy);
    int now=1;
    srand( time(NULL) );
    for (int i = 0; i < D; ++i) {
        t[i]=now;
        //now=min(now+1,26);
        now=rand () % 26+1;
        if(now>26)now=1;
    }

    return 0;

}

int score(){
    satisfaction=0;
    last=last0;
    for (int d = 0; d < D; ++d) {
        int i = t[d]-1;
        satisfaction+=ss[d][i];

        last[i]=d+1;
        for (int cc = 0; cc < 26; ++cc) {
            satisfaction-=c[cc]*((d+1)-last[cc]);
        }
        //cout<<satisfaction<<endl;
    }

    return satisfaction;
}
int hajime = clock();
uint64_t get_rand_range( uint64_t min_val, uint64_t max_val ) {
    // 乱数生成器
    static std::mt19937_64 mt64(0);

    // [min_val, max_val] の一様分布整数 (int) の分布生成器
    std::uniform_int_distribution<uint64_t> get_rand_uni_int( min_val, max_val );

    // 乱数を生成
    return get_rand_uni_int(mt64);
}
int loop(){
    int old_score=init_score;
    int new_score=0;
    srand( time(NULL) );
    int cnt=0;
    while(cnt<=20000000){
        if ((clock() - hajime) > 1.85 * CLOCKS_PER_SEC) break;
        for (int d = 0; d < D; ++d) {
            int now=t[d];
            //t[d]++;
            //t[d]=min(t[d]+1,26);
            if(cnt%1000==0){
                //t[d]=v[1].second;
                t[d]=get_rand_range(1,26);
            }else t[d]=get_rand_range(1,26);

            new_score=score();
            if(new_score<=old_score){
                t[d]=now;
                continue;
            }else{
                old_score=new_score;
                //cout<<cnt<<" "<<d<<" "<<new_score<<endl;
            }
            if(cnt%10==0){
                //t[d]=3;
                t[d]=get_rand_range(1,26);
            }


        }
        cnt++;
        //cout<<cnt<<endl;
    }



    return 0;
}

int main() {
    IOS;
    prec;


    cin>>D;
    rep(i,0,26)cin>>c[i];
    for (int k = 0; k < 26; ++k) {
        v[k] = make_pair(c[k], k+1);
    }
    sort(v.begin(),v.end());

    //for (auto V : v) {
    //    cout << V.first << " " << V.second << endl;
    //
    //}
    for (int y = 0; y < D; ++y) {
        for (int x = 0; x < 26; ++x) {
            cin>>ss[y][x];
        }
    }
    //rep(i,0,D)cin>>t[i];
    //cout<<score();
    init();
    init_score=score();
    //printV(t);
    loop();
    //printV(t);
    for (int j = 0; j < D; ++j) {
        cout<<t[j]<<endl;
    }
    //cout<<score();









    cout<<endl;
    return 0;
}


Measured memory_bytes: 3728