#include <bits/stdc++.h>
using namespace std;
using ll = long long;

mt19937 mt;

struct Settings {
    int D;
    int TMAX = 26;
    vector<ll> C;
    vector<vector<ll>> S;
    Settings(int d, vector<ll>& c, vector<vector<ll>>& s) : D(d), C(c), S(s) {}
};

struct Schedule {
    Settings& ss;
    vector<int> T;  // T[d]: type of day d+1, T[d]=-1:invalid
    vector<set<int>> ts; // ts[ty]: indexes of ty
    ll score = 0;
    Schedule(Settings& ss) : ss(ss) {
        ts.assign(ss.TMAX, set<int>());
        T.assign(ss.D, -1);
        score = 0;
        for ( int t = 0; t < ss.TMAX; t++ ) {
            ts[t].insert(-1);
            int dd = ss.D+1;
            score -= dd*(dd-1)/2 * ss.C[t];
            ts[t].insert(ss.D);
        }
    }
    // d+1日目の種類をq+1に変える
    void change(int d, int q) {
        // remove
        if ( T[d] >= 0 ) {
            auto p = ts[T[d]].find(d);
            auto p_prev = prev(p), p_next = next(p);
            score -= (d-*p_prev) * (*p_next-d) * ss.C[T[d]];
            score -= ss.S[d][T[d]];
            ts[T[d]].erase(d);
            T[d] = -1;
        }
        // add
        if ( q >= 0 ) {
            T[d] = q;
            ts[T[d]].insert(d);
            auto p = ts[T[d]].find(d);
            auto p_prev = prev(p), p_next = next(p);
            score += (d-*p_prev) * (*p_next-d) * ss.C[T[d]];
            score += ss.S[d][T[d]];
        }
    }
};

// テストデータ作成
Settings CreateSettings() {
    uniform_int_distribution<int> rnd_c(0, 100);
    uniform_int_distribution<int> rnd_s(0, 20000);
    ll D = 365;
    vector<ll> C(26);
    for ( int i = 0; i < 26; i++ ) {
        C[i] = rnd_c(mt);
    }
    vector<vector<ll>> S(D, vector<ll>(26));
    for ( int i = 0; i < D; i++ ) {
        for ( int j = 0; j < 26; j++ ) {
            S[i][j] = rnd_s(mt);
        }
    }
    Settings ss(D,C,S);
    return ss;
}

// 貪欲法 dd:[0,D)の順列
void greedy(Schedule& sch, vector<int>& dd) {
    auto& ss = sch.ss;
    vector<int> T(ss.D,-1);
    for ( int d : dd ) {
        ll sc = -(1LL<<60);
        for ( int q = 0; q < ss.TMAX; q++ ) {
            sch.change(d,q);
            if ( sc < sch.score ) {
                T[d] = q;
                sc = sch.score;
            }
        }
        sch.change(d,T[d]);
    }
}
// 貪欲法 日付順ランダム
void greedy_rand(Schedule& sch, int cnt = 1) {
    vector<int> dd(sch.ss.D);
    for ( int i = 0; i < sch.ss.D; i++ ) dd[i] = i;
    while ( cnt-- ) {
        shuffle(dd.begin(), dd.end(), mt);
        greedy(sch, dd);
    }
}
void trial_rand(Schedule& sch, int sz = 1, int cnt = 1) {
    uniform_int_distribution<int> rnd_d(0, sch.ss.D-1);
    uniform_int_distribution<int> rnd_t(0, sch.ss.TMAX-1);
    while ( cnt-- ) {
        ll sc = sch.score;
        stack<tuple<int,int>> old;
        int d, t;
        for ( int i = 0; i < sz; i++ ) {
            d = rnd_d(mt), 
            t = rnd_t(mt);
            old.push(make_tuple(d, sch.T[d]));
            sch.change(d, t);
        }
        if ( sch.score < sc ) {
            while ( !old.empty() ) {
                tie(d,t) = old.top();
                old.pop();
                sch.change(d, t);
            }
        } else {
            while ( !old.empty() ) old.pop();
        }
    }
}
void trial_swap_type(Schedule& sch, int cnt = 1, int d_dist = 20) {
    uniform_int_distribution<int> rnd_d(0, sch.ss.D-1);
    uniform_int_distribution<int> rnd_dd(1, d_dist);
    while ( cnt-- ) {
        ll sc = sch.score;
        int d1 = rnd_d(mt), d2 = d1 + rnd_dd(mt);
        if ( d2 >= sch.ss.D ) continue;
        int t1 = sch.T[d1], t2 = sch.T[d2];
        sch.change(d1, t2);
        sch.change(d2, t1);
        if ( sch.score < sc ) {
            sch.change(d1, t1);
            sch.change(d2, t2);
        }
    }
}

ll loop_duration (function<void(int)> proc, chrono::system_clock::time_point break_time, ll init_lp = 1) {
    int lp = init_lp, lpc = 0;;
    chrono::system_clock::time_point t_begin = chrono::system_clock::now();
    while ( true ) {
        lpc += lp;
        proc(lp);
        auto t_end = chrono::system_clock::now();
        auto dur0 = chrono::duration_cast<chrono::milliseconds>(break_time-t_end);
        // cout << "dur0:" << dur0.count() << "\n";
        if ( break_time < t_end ) break;
        auto dur = chrono::duration_cast<chrono::milliseconds>(t_end-t_begin);
        if ( dur.count() < 25 ) lp *= 2;
        else if ( dur.count() > 100 ) lp /= 2;
        t_begin = t_end;
    }
    return lpc;
}

ll test_main() {
    auto t_start = chrono::system_clock::now();
    Settings ss = CreateSettings();
    Schedule sch(ss);
    
    int out_id = 0;
    auto out_score = [&]() {
        cout << out_id++ << ": " << sch.score << "\n";
    };
    out_score();
    // 初期値設定
    // greedy_rand(sch);
    // out_score();
    // greedy_rand(sch, 4);
    // out_score();
    // greedy_rand(sch);
    // out_score();
    // cout << "\n";
    // trial_rand(sch, 1, 1000);
    // out_score();
    // trial_rand(sch, 1, 4000);
    // out_score();

    // greedy_rand(sch, 1);
    // trial_rand(sch, 2, 1000);
    // greedy_rand(sch, 1);
    int cf = 1;
    for ( int i = 0; i < 10000/cf; i++ ) {
        trial_rand(sch, 2, 9*cf);
        trial_rand(sch, 3, 1*cf);
        trial_swap_type(sch, 9*cf, 20);
        trial_swap_type(sch, 1*cf, 5);
        if ( i % (100/cf) == 0 ) out_score();
    }
    trial_rand(sch, 2, 10000);
    out_score();

    // for ( int i = 0; i < 200; i++ ) {
    //     trial_rand(sch, 2, 5000);
    //     trial_rand(sch, 1000);
    //     out_score();
    // }


    cout << "\n";
    out_score();
    auto t_limit = t_start + chrono::milliseconds(1900);
    ll lp_c = loop_duration(
        [&](ll lp) {trial_rand(sch, 1, lp);},
        t_limit,
        1000
    );
    out_score();
    cout << "loop:" << lp_c << "\n";

    // for ( int d = 0; d < ss.D; d++ ) {
    //     cout << sch.T[d]+1 << "\n";
    // }   
    
    ll ans = 0;
    return ans;
}

ll solve_main() {
    auto t_start = chrono::system_clock::now();
    mt = mt19937(0);
    // input
    ll D;
    cin >> D;
    vector<ll> C(26);
    for ( int i = 0; i < 26; i++ ) cin >> C[i];
    vector<vector<ll>> S(D, vector<ll>(26));
    for ( int i = 0; i < D; i++ ) {
        for ( int j = 0; j < 26; j++ ) cin >> S[i][j];
    }
    Settings ss(D,C,S);
    vector<Schedule> sch = {Schedule(ss), Schedule(ss), Schedule(ss)};
    auto t_start_loop = chrono::system_clock::now();
    ll sc = -(1LL<<60);
    int mi = -1;
    for ( int i = 0; i < 3; i++ ) {
        auto t_limit = t_start_loop + chrono::milliseconds((i+1)*500);
        greedy_rand(sch[i], 7);
        trial_rand(sch[i], 1, 5000);
        ll lp_c = loop_duration(
            [&](ll lp) {
                for ( int j = 0; j < lp; j++ ) {
                    trial_rand(sch[i], 2, 9);
                    trial_rand(sch[i], 3, 1);
                    trial_swap_type(sch[i], 9, 20);
                    trial_swap_type(sch[i], 1, 5);
                }
            },
            t_limit,
            100
        );
        trial_rand(sch[i], 2, 10000);
        if ( sc < sch[i].score ) {
            sc = sch[i].score;
            mi = i;
        }
    }
    // cout << sc << "\n";

    for ( int d = 0; d < ss.D; d++ ) {
        cout << sch[mi].T[d]+1 << "\n";
    }
    return 0;
}

int main() {
    mt = mt19937(0);
    // test_main();
    solve_main();
    return 0;
}

Measured memory_bytes: 3896