//{{{
#include<algorithm>
#include<cmath>
#include<cstring>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printde4) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

#define LIMIT 2.0
// #define LIMIT 4.0

using scr = int;
mt19937 mt;

/*
TODO
*/

// structs
// {{{ Counter
struct Counter{
#ifdef LOCAL
#define COUNTER(name) Counter name(#name);
    int cnt = 0;
    string name;
    Counter(string name): name(name){ }
    ~Counter(){ printde(name, cnt); }
    void operator ++ (int){ cnt++; }
    void operator += (int d){ cnt += d; }
#else
#define COUNTER(name) Counter name;
    void operator ++ (int){ }
    void operator += (int){ }
#endif
};
// }}}
// COUNTER(cnt)
COUNTER(trial)
COUNTER(accepted)

// {{{ Watch
struct Watch {
    double prev;
    double getPrev(){
        return prev;
    }
#ifdef LOCAL
    timeval start;
    Watch(){
        gettimeofday(&start, nullptr);
    }
    double elapsed(){
        timeval now;
        gettimeofday(&now, nullptr);
        return prev = (now.tv_sec - start.tv_sec) + (now.tv_usec - start.tv_usec) / 1e6;
    }
#else
    double start;
#define ticks_per_sec 2800000000.0
    Watch(){
        start = get_time();
    }
    double elapsed(){
        return prev = get_time() - start;
    }
private:
    double get_time(){
        uint32_t lo, hi;
        asm volatile ("rdtsc" : "=a" (lo), "=d" (hi));
        return (((uint64_t)hi << 32) | lo) / ticks_per_sec;
    }
#endif
} watch;
// }}}

// {{{ Ans
struct Ans {
    scr score = -M;
    vector<int> ts;
    void output();
} bestAns;
// }}}

// constants
constexpr int D = 365;
int cs[26];
int ss[D][26];


// {{{ functions
// }}}


struct Problem : Ans{
    // variables
    vector<vector<int>> days;

    scr calcOne(int d1, int d2);
    scr calc();
    void makeInit();
    void solve();
    void initialize();
    void input();
    void updateBestScore(Ans& ans = bestAns);

};

void Problem::initialize(){ //{{{
    days.resize(26, vector<int>({-1, 365}));
    // days.resize(26, vector<int>({-1, 364}));
} //}}}

void Problem::updateBestScore(Ans& ans){ //{{{
    if(ans.score < score){
        ans = *this;
        printde("best", ans.score);
    }
} //}}}


scr Problem::calcOne(int d1, int d2){ //{{{
    int diff = d2 - 1 - d1;
    return diff * (diff + 1) / 2;
} //}}}

scr Problem::calc(){
    scr ret = 0;
    for(int i = 0; i < D; i++){
        ret += ss[i][ts[i]];
    }
    for(int i = 0; i < 26; i++){
        for(size_t j = 1; j < days[i].size(); j++){
            ret -= cs[i] * calcOne(days[i][j - 1], days[i][j]);
        }
    }
    return ret;
}

void Problem::makeInit(){ //{{{
    // vector<int> cacc(26);
    // for(int i = 0; i < 26; i++){
    //     cacc[i] = cs[i] + (i ? cacc[i - 1] : 0);
    // }
    // int acc = accumulate(cs, cs + 26, 0ll);
    // for(int i = 0; i < D; i++){
    //     int rd = mt() % acc;
    //     for(int j = 0; j < 26; j++){
    //         rd -= cs[j];
    //         if(rd < 0){
    //             ts.push_back(j);
    //             break;
    //         }
    //     }
    // }

    for(int i = 0; i < D; i++){
        ts.push_back(i % 26);
        // days[i % 26].push_back(i);
        days[i % 26].insert(days[i % 26].begin() + days[i % 26].size() - 1, i);
    }

    // for(int i = 0; i < D; i++){
    //     ts.push_back(0);
    //     maxi = ;
    //     for(int j = 1; j < 26; j++){
    //         ts.back() = j;
    //     }
    // }

    score = calc();
    bestAns = *this;
} //}}}

void Problem::solve(){
    static const double startT = 2000, endT = 0.1;
    int acc = 0;
    for(int i = 0; i < 26; i++){
        acc += days[i].size();
    }
    printde(acc);
    while(watch.elapsed() < LIMIT){
        double temp = startT + (endT - startT) * min(1.0, watch.getPrev() / LIMIT);
        for(int _ = 0; _ < 50; _++) {
            if(mt() % 100 < 25){
                int d = mt() % D;
                scr diff = 0;
                int prev = ts[d];
                int dprev2;
                auto& dprev3 = days[prev];
                diff -= ss[d][prev];
                for(size_t i = 0; i < dprev3.size(); i++){
                    auto& day = dprev3[i];
                    if(day == d){
                        diff += cs[prev] * (calcOne(dprev3[i - 1], dprev3[i]) + calcOne(dprev3[i], dprev3[i + 1]));
                        diff -= cs[prev] * (calcOne(dprev3[i - 1], dprev3[i + 1]));
                        dprev2 = i;
                        break;
                    }
                }
                int next;
                do{
                    next = mt() % 26;
                }while(prev == next);
                ts[d] = next;
                int dnext2;
                auto& dnext3 = days[next];
                diff += ss[d][next];
                for(size_t i = 0; i < dnext3.size(); i++){
                    auto& day = dnext3[i];
                    if(d <= day){
                        diff += cs[next] * (calcOne(dnext3[i - 1], dnext3[i]));
                        diff -= cs[next] * (calcOne(dnext3[i - 1], d) + calcOne(d, dnext3[i]));
                        dnext2 = i;
                        break;
                    }
                }
                trial++;
                bool changeCond = true ? exp(diff / temp) * (1ull << 32) > mt() : diff >= 0;
                if(changeCond){
                    accepted++;
                    score += diff;
                    days[prev].erase(days[prev].begin() + dprev2);
                    days[next].insert(days[next].begin() + dnext2, d);
                    updateBestScore();
                }else{
                    ts[d] = prev;
                }
            }else{
                int d1 = mt() % D;
                int d2;
                do{
                    d2 = mt() % D;
                }while(d1 == d2);
                scr diff = 0;
                int t1 = ts[d1];
                int t2 = ts[d2];
                auto& days1 = days[t1];
                auto& days2 = days[t2];
                diff -= ss[d1][t1];
                diff -= ss[d2][t2];
                diff += ss[d1][t2];
                diff += ss[d2][t1];
                int i1, j1;
                for(size_t i = 0; i < days1.size(); i++){
                    if(days1[i] == d1){
                        i1 = i;
                        for(size_t j = 0; j < days2.size(); j++){
                            if(days2[j] == d2){
                                j1 = j;
                    diff += cs[t1] * (calcOne(days1[i - 1], days1[i]) + calcOne(days1[i], days1[i + 1]));
                    diff += cs[t2] * (calcOne(days2[j - 1], days2[j]) + calcOne(days2[j], days2[j + 1]));
                    diff -= cs[t1] * (calcOne(days1[i - 1], days2[j]) + calcOne(days2[j], days1[i + 1]));
                    diff -= cs[t2] * (calcOne(days2[j - 1], days1[i]) + calcOne(days1[i], days2[j + 1]));
                            }
                        }
                        break;
                    }
                }
                trial++;
                bool changeCond = true ? exp(diff / temp) * (1ull << 32) > mt() : diff >= 0;
                if(changeCond){
                    accepted++;
                    score += diff;
                    updateBestScore();
                    ts[d1] = t2;
                    ts[d2] = t1;
                    swap(days1[i1], days2[j1]);
                }else{
                }
            }
        }
    }
    // printde(days);
    acc = 0;
    for(int i = 0; i < 26; i++){
        acc += days[i].size();
    }
    printde(acc);
}

// {{{ input output
void Problem::input(){
    int d; cin >> d;
    for(int i = 0; i < 26; i++){
        cin >> cs[i];
    }
    for(int i = 0; i < d; i++){
        for(int j = 0; j < 26; j++){
            cin >> ss[i][j];
        }
    }
}

void Ans::output(){
    for(int i = 0; i < D; i++){
        cout << ts[i] + 1 << '\n';
    }
}
// }}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    Problem problem;
    problem.input();
    problem.initialize();
    problem.makeInit();
    problem.solve();
    bestAns.output();
}


Measured memory_bytes: 3848