//{{{
#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.1
// #define LIMIT 4.0

using scr = int;
// mt19937 mt = mt19937(2);
mt19937 mt;
uniform_real_distribution<> dist(0.0, 1.0);


/*
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];
scr calcOneArr[367];


// {{{ functions
int mtExcept(int width, int ex){
    int ret = mt() % (width - 1);
    return ret + (ret == ex);
}
// }}}


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

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

void Problem::initialize(){ //{{{
    days.resize(26, vector<int>({-1, 365}));
    offs.resize(26, vector<int>(365));
    // days.resize(26, vector<int>({-1, 364}));
    for(int i = 0; i <= D + 1; i++){
        calcOneArr[i] = i * (i + 1) >> 1;
    }
} //}}}

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


scr Problem::calcOne(int d1, int d2){ //{{{
    // return calcOneArr2[d1][d2];
    int diff = d2 - 1 - d1;
    return calcOneArr[diff];
    // if(diff * (diff + 1) >> 1 != calcOneArr2[d1][d2]){
    //     printde(d1, d2, diff * (diff + 1) >> 1, calcOneArr2[d1][d2]);
    // }
    // return diff * (diff + 1) >> 1;
    // 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::updateOffs(int type){ //{{{
    int idx = days[type].size() - 1;
    for(int j = D - 1; j >= 0; j--){
        if(days[type][idx - 1] == j){
            idx--;
        }
        offs[type][j] = idx;
    }
} //}}}

void Problem::makeInit(){ //{{{
    for(int i = 0; i < D; i++){
        ts.emplace_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 < 26; i++){
        updateOffs(i);
    }
    score = calc();
    bestAns = *this;
} //}}}

// void changeOne();
// void Problem::changeOne(){ //{{{
// } //}}}

void Problem::solve(){
    constexpr double log1e32 = 22.180709777918249159256447455845773220062255859375;
    static const double startT = 1500, endT = 0.1;
    int acc = 0;
    for(int i = 0; i < 26; i++){
        acc += days[i].size();
    }
    printde(acc);
    auto calcPartial = [&](int type, int d1, int d2, int d3){ 
        scr diff = 0;
        diff += ss[d2][type];
        diff -= cs[type] * (calcOne(d1, d2) + calcOne(d2, d3));
        diff += cs[type] * (calcOne(d1, d3));
        return diff;
    };
    while(watch.elapsed() < LIMIT){
        double temp = startT + (endT - startT) * min(1.0, watch.getPrev() / LIMIT);
        for(int _ = 0; _ < 50; _++) {
            trial++;
            if(mt() % 100 < 25){
                int d = mt() % D;
                scr diff = 0;
                int prev = ts[d];
                int i1 = offs[prev][d];
                auto& days1 = days[prev];
                diff -= calcPartial(prev, days1[i1 - 1], days1[i1], days1[i1 + 1]);
                int next = mtExcept(26, prev);
                auto& days2 = days[next];
                int j1 = offs[next][d];
                diff += calcPartial(next, days2[j1 - 1], d, days2[j1]);
                // bool changeCond = true ? diff > temp * log(dist(mt)) : diff >= 0;
                bool changeCond = true ? diff > temp * (log(mt()) - log1e32) : diff >= 0;
                // bool changeCond = true ? diff > temp * (log(mt()) - log(double(1ull << 32))) : diff >= 0;
                // bool changeCond = true ? diff > temp * log(mt() / double(1ull << 32)) : diff >= 0;
                // bool changeCond = true ? exp(diff / temp) * (1ull << 32) > mt() : diff >= 0;
                if(changeCond){
                    accepted++;
                    score += diff;
                    ts[d] = next;
                    days1.erase(days1.begin() + i1);
                    days2.insert(days2.begin() + j1, d);
                    updateOffs(prev);
                    updateOffs(next);
                    updateBestScore();
                }
            }else{
                int day1 = mt() % D;
                int prev = ts[day1];
                auto& days1 = days[prev];
                int day2;
                do{
                    day2 = day1 + mt() % 41 - 20;
                    // day2 = mt() % D;
                }while(day2 < 0 || day2 >= D || prev == ts[day2]);
                int next = ts[day2];
                auto& days2 = days[next];
                int i1 = offs[prev][day1];
                int i2 = offs[prev][day2];
                int j1 = offs[next][day2];
                int j2 = offs[next][day1];
                scr diff = 0;
                diff -= calcPartial(prev, days1[i1 - 1], day1, days1[i1 + 1]);
                diff += calcPartial(prev, days1[i2 - 1 - (i1 == i2 - 1)], day2, days1[i2 + (i1 == i2)]);
                diff -= calcPartial(next, days2[j1 - 1], day2, days2[j1 + 1]);
                diff += calcPartial(next, days2[j2 - 1 - (j1 == j2 - 1)], day1, days2[j2 + (j1 == j2)]);
                bool changeCond = true ? diff > temp * (log(mt()) - log1e32) : diff >= 0;
                // bool changeCond = true ? exp(diff / temp) * (1ull << 32) > mt() : diff >= 0;
                if(changeCond){
                    accepted++;
                    score += diff;
                    swap(ts[day1], ts[day2]);
                    if(i1 == i2){
                        days1[i1] = day2;
                    }else if(i1 > i2){
                        days1.erase(days1.begin() + i1);
                        days1.insert(days1.begin() + i2, day2);
                    }else{
                        days1.insert(days1.begin() + i2, day2);
                        days1.erase(days1.begin() + i1);
                    }
                    if(j1 == j2){
                        days2[j1] = day1;
                    }else if(j1 > j2){
                        days2.erase(days2.begin() + j1);
                        days2.insert(days2.begin() + j2, day1);
                    }else{
                        days2.insert(days2.begin() + j2, day1);
                        days2.erase(days2.begin() + j1);
                    }
                    updateOffs(prev);
                    updateOffs(next);
                    updateBestScore();
                }
            }
        }
    }
    // 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: 3592