#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64
#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
//#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
#define ins(v, x) (v).insert(lower_bound(all(v), x), x)
template <typename T1, typename T2> inline void chmin(T1& a, T2 b) {
    if (a > b) a = b;
}
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) {
    if (a < b) a = b;
}
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7;
constexpr int MAX = 10050;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e18 + 1;
constexpr int INF = 1e9 + 1;
using ull = uint64_t;
unsigned long xor128(void) {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t;
    t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
constexpr int N = 26;
int D;
int C[30];
int S[400][30];

int16_t las[400][N + 1];
int gain = 0, ngain = 0;
// int loss[30];
int loss = 0;
int losses[30][400];
int lss[30];
int16_t ans[400];
vector<int16_t> position[N];
int calc_score_init() {
    int ret = 0;
    gain = 0;
    REP(j, N) {
        position[j].push_back(-1);
        position[j].push_back(D);
        las[0][j] = -1;
        losses[j][0] = 0;
    }
    REP(i, D) {
        int j = ans[i];
        position[j].insert(lower_bound(all(position[j]), i), i);
        ret += S[i][j];
        gain += S[i][j];
        las[i][j] = i;
        REP(k, N) {
            ret -= C[k] * (i - las[i][k]);
            loss += C[k] * (i - las[i][k]);
            losses[k][i + 1] = losses[k][i] + C[k] * (i - las[i][k]);
        }
        REP(k, N) { las[i + 1][k] = las[i][k]; }
    }
    REP(k, N) lss[k] += losses[k][D];
    return ret;
}

int calcmax(vector<int>& ans) {
    int d = ans.size();
    REP(j, N) las[0][j] = -1;
    REP(i, d) {
        int j = ans[i];
        las[i][j] = i;
        REP(k, N) { las[i + 1][k] = las[i][k]; }
    }
    int idx = 0;
    int score = -INF;
    REP(j, N) {
        int res = S[d][j];
        REP(k, N) {
            if (k != j) res -= C[k] * (d - las[d][k]);
        }
        if (res > score) {
            score = res;
            idx = j;
        }
    }
    return idx;
}

void input() {
    cin >> D;
    REP(i, N) cin >> C[i];
    REP(i, D) {
        REP(j, N) { cin >> S[i][j]; }
    }
}

void update_loss(int j) {
    // DEBUG(j);
    lss[j] = 0;
    if (position[j].empty()) return;
    for (int i = 1; i < (int)position[j].size(); i++) {
        // DEBUG(i);
        int l = position[j][i] - position[j][i - 1] - 1;
        lss[j] += C[j] * l * (l + 1) / 2;
    }
    // cerr << "done" << endl;
}

int ret[400];

void fail(string s) {
    cerr << s << endl;
    exit(1);
}

void erase(vector<int16_t>& v, int j, int i) {
    auto itr = lb(v, i);
    int idx = itr - v.begin();  //
    lss[j] -= C[j] * (v[idx] * v[idx] + v[idx + 1] * v[idx - 1] - v[idx - 1] * v[idx] - v[idx + 1] * v[idx]);
    // lss[j] -= C[j] * (v[idx] - v[idx - 1]) * (v[idx] - v[idx - 1] - 1) / 2;
    // lss[j] -= C[j] * (v[idx + 1] - v[idx]) * (v[idx + 1] - v[idx] - 1) / 2;
    // lss[j] += C[j] * (v[idx + 1] - v[idx - 1]) * (v[idx + 1] - v[idx - 1] - 1) / 2;
    v.erase(itr);
}
void insert(vector<int16_t>& v, int j, int i) {
    auto itr = lb(v, i);
    int idx = itr - v.begin();
    lss[j] += C[j] * (i * i + v[idx] * (v[idx - 1] - i) - v[idx - 1] * i);
    // lss[j] -= C[j] * (v[idx] - v[idx - 1]) * (v[idx] - v[idx - 1] - 1) / 2;
    // lss[j] += C[j] * (i - v[idx - 1]) * (i - v[idx - 1] - 1) / 2;
    // lss[j] += C[j] * (v[idx] - i) * (v[idx] - i - 1) / 2;
    v.insert(itr, i);
}

void solve() {
    input();
    // cerr<<"a"<<endl;
    const double LIMIT = 1970;
    int t = 0;
    double start_temp = 2000, end_temp = 10;
    clock_t start = clock();
    int accepted = 0;
    double TIME = 0;
    const double m = (end_temp - start_temp) / LIMIT;
    int pre_val = 0, new_val = 0;
    double temp = start_temp;

    vector<int> tmp;
    REP(i, D) {
        tmp.push_back(calcmax(tmp));
        ans[i] = tmp[i];
    }
    pre_val = new_val = calc_score_init();
    int best_score = pre_val;
    cerr << "initial score:" << pre_val << endl;
    // REP(j, N) update_loss(j);
    int tm = gain;
    while (true) {
        t++;
        if (t % 1000 == 0) {
            clock_t end = clock();
            TIME = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
            if (TIME > LIMIT) goto END;
        }
        bool sign = xor128() & 1;
        // int sign = xor128()%5;
        int x = 0;
        int y = 0;
        // int mn = min(x, y);
        int z = xor128() % N;
        while (z == ans[x]) z = xor128() % N;
        int jx = ans[x], jy = 0;
        new_val = pre_val;
        // swap
        if (sign) {
            int width = xor128() % 15 + 1;
            x = xor128() % (D - width);
            y = x + width;
            jx = ans[x];
            jy = ans[y];
            // if (!position[jx].count(x) || !position[jy].count(y)) fail("swap: cannot erase");
            new_val = new_val - (S[x][jx] + S[y][jy]) + (S[x][jy] + S[y][jx]);
            new_val += lss[jx] + lss[jy];
            erase(position[jx], jx, x);
            erase(position[jy], jy, y);
            insert(position[jx], jx, y);
            insert(position[jy], jy, x);
            swap(ans[x], ans[y]);
            new_val -= (lss[jx] + lss[jy]);
        }
        // update
        else {
            x = xor128() % D;
            jx = ans[x];
            // if (!position[jx].count(x)) fail("update: cannot erase");
            // if (position[z].count(x)) fail("update: cannot insert");
            ans[x] = z;
            new_val = new_val - S[x][jx] + S[x][z];
            new_val += lss[jx] + lss[z];
            erase(position[jx], jx, x);
            insert(position[z], z, x);
            new_val -= (lss[jx] + lss[z]);
        }
        // temp*=0.999995;
        temp = start_temp + m * TIME;
        double prob = exp((new_val - pre_val) / temp);
        // if too bad
        if (new_val < pre_val - 100000) {
            if (sign) {
                jx = ans[x], jy = ans[y];
                erase(position[jx], jx, x);
                erase(position[jy], jy, y);
                insert(position[jx], jx, y);
                insert(position[jy], jy, x);
                swap(ans[x], ans[y]);
            } else {
                ans[x] = jx;
                erase(position[z], z, x);
                insert(position[jx], jx, x);
            }
        } else if (new_val > pre_val || prob > (xor128() % INF) / (double)INF) {
            // if(!sign)calc_score_init(ans);
            pre_val = new_val;
            if (new_val > best_score) {
                best_score = new_val;
                REP(i, D) ret[i] = ans[i];
            }
            // chmax(best_score, new_val);
            accepted++;
            continue;
        } else {
            if (sign) {
                jx = ans[x], jy = ans[y];
                erase(position[jx], jx, x);
                erase(position[jy], jy, y);
                insert(position[jx], jx, y);
                insert(position[jy], jy, x);
                swap(ans[x], ans[y]);
            } else {
                ans[x] = jx;
                erase(position[z], z, x);
                insert(position[jx], jx, x);
            }
        }
    }
END:;
    cerr << "temp:" << temp << endl;
    cerr << "accepted:" << (double)accepted / t << endl;
    cerr << "iteration:" << t << '\n';
    cerr << "score:" << best_score << '\n';

    // output
    REP(i, D) { print(ret[i] + 1); }
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    // int q;
    // cin >> q;
    // while (q--)
    solve();
}


Measured memory_bytes: 4580