#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

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

constexpr int mod = (1<<30)-1;

inline double getprob(){
    return (xor128()%mod)/(double) mod;
}

class TimeCheck {
private:
    chrono::system_clock::time_point start, end;

public:
    TimeCheck(){start = chrono::system_clock::now();}

    double nowTime() {
        end = chrono::system_clock::now();
        double ti = static_cast<double>(
            chrono::duration_cast<chrono::microseconds>(end-start).count()/1000.0);
        return ti;
    }
};

const int D = 365;
const int M = 26;
vec<int> C(M);
int Csum = 0;
vvec<int> S(D,vec<int>(M));

int getRndDay(){
    return xor128()%D;
}

int getRnd(int n){
    return xor128()%n;
}

using arr = array<int,M>;

struct state{
    vec<int> res;
    int day;
    arr last;
    int score;
    int weight = 0;
    state(){
        last = {};
        score = 0;
        day = 0;
    }
    void add(int type){
        day++;
        score += S[(int) res.size()][type];
        res.push_back(type);
        weight += Csum;
        weight -= C[type]*(day-last[type]);
        score -= weight;
        last[type] = day;
    }

    bool operator<(const state& R)const{
        return score>R.score;
    }

    void print(){
        for(auto& x:res) cout << x+1 << "\n";
    }
};

const int width = 200;
const int lower = 12000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    TimeCheck TC;
    int d;
    cin >> d;
    for(auto& x:C){
        cin >> x;
        Csum += x;
    }
    for(auto& v:S) for(auto& x:v) cin >> x;
    state init;
    vec<state> states;
    vvec<int> good(D);
    for(int i=0;i<D;i++){
        for(int j=0;j<M;j++) if(S[i][j]>=lower) good[i].push_back(j);
    }
    states.push_back(init);
    for(int d=0;d<D;d++){
        vec<state> neS;
        for(auto& now:states){
            vec<state> comp;
            for(auto& x:good[d]){
                state ne = now;
                ne.add(x);
                comp.push_back(ne);
            }
            sort(comp.begin(),comp.end());
            if(comp.size()>7) comp.resize(7);
            for(auto& x:comp) neS.push_back(x);
        }
        sort(neS.begin(),neS.end());
        if(neS.size()>width) neS.resize(width);
        states.swap(neS);
    }

    auto now = states[0];
    cerr << now.score << "\n";
    vvec<int> s(M);
    for(int i=0;i<D;i++) s[now.res[i]].push_back(i);
    for(int i=0;i<M;i++){
        s[i].push_back(-1);
        s[i].push_back(D);
        sort(s[i].begin(),s[i].end());
    }

    auto getsum = [&](int len){
        assert(len>=0);
        return len*(len+1)/2;
    };

    auto insert = [&](int day,int type){
        int delta = 0;
        auto r = upper_bound(s[type].begin(),s[type].end(),day);
        auto l = r;
        l--;
        delta += (-getsum(*r-day-1)-getsum(day-*l-1)+getsum(*r-*l-1))*C[type];
        delta += S[day][type];
        s[type].insert(r,day);
        now.res[day] = type;
        return delta;
    };

    auto erase = [&](int day,int type){
        int delta = 0;
        auto r = upper_bound(s[type].begin(),s[type].end(),day);
        auto d = r;
        d--;
        auto l = r;
        l--;
        l--;
        delta += (getsum(*r-day-1)+getsum(day-*l-1)-getsum(*r-*l-1))*C[type];
        delta -= S[day][type];
        s[type].erase(d);
        now.res[day] = -1;
        return delta;
    };

    auto update = [&](int day,int t1,int t2){
        int delta = 0;
        delta += erase(day,t1);
        delta += insert(day,t2);
        return delta;
    };

    auto swapping = [&](int d1,int d2){
        int delta = 0;
        int t1 = now.res[d1],t2 = now.res[d2];
        delta += erase(d1,t1)+erase(d2,t2);
        delta += insert(d1,t2)+insert(d2,t1);
        return delta;
    };

    int loop = 0,up = 0;
    constexpr double start_temp = 3000.0;
    constexpr double end_temp = 10.0;
    constexpr double TL = 2000.0;
    double now_time = TC.nowTime();
    while(now_time<1950){
        int day = getRndDay();
        int nowScore = now.score;
        int n = good[day].size();
        if(n==1) continue;
        if(0.5>getprob()){
            int nowType = now.res[day];
            int nextType = good[day][getRnd(n)];
            loop++;
            if(nextType == nowType){
                continue;
            }
            if(loop%1000==0){
                now_time = TC.nowTime();
            }
            int delta = update(day,nowType,nextType);
            double prob = exp(delta/(start_temp+(end_temp-start_temp)*now_time/TL));
            if(prob > getprob()){
                up++;
                now.score += delta;
            }else{
                update(day,nextType,nowType);
            }
        }else{
            int dd = getRnd(10);
            if(!dd) dd++;
            int d1 = day,d2 = (day+dd<D? day+dd:day-dd);
            if(d2>d1) swap(d1,d2);
            int delta = swapping(d1,d2);
            double prob = exp(delta/(start_temp+(end_temp-start_temp)*now_time/TL));
            if(prob > getprob()){
                up++;
                now.score += delta;
            }else{
                swapping(d1,d2);
            }
        }
    }
    cerr << loop << " " << up << "\n";
    cerr << now.score << "\n";
    now.print();
}


Measured memory_bytes: 7744