#include <bits/stdc++.h>
#include <time.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n,m) for (int i = (n); i <= (m); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int d;
int c[26];
int s[365][26];

map<int,int> exist[26];
int sum[26];

map<int,int> tabu;
int iteration = 1000;

int sigma(int x) { return (x+1)*x/2; }

void make_sum(int i) {
    sum[i]=0;
    int last = -1;
    for (auto x:exist[i]) {
        sum[i] += sigma(x.first-last-1);
        last = x.first;
    }
    sum[i] += sigma(d-1-last);
    /*cout << "i=" << (i+1) << ":";
      for (auto x:exist[i]) cout << x << ",";
      cout <<sum[i]<< endl;*/
}


void sol_init(int order[]) {
    rep(i,26) exist[i].clear();
    rep(j,d)  exist[order[j]][j]=1;
    rep(i,26) make_sum(i);
}

int sol_val(int order[]) {
    int ans = 0;
    rep(j,d)  ans += s[j][order[j]];
    rep(i,26) ans -= c[i]*sum[i];
    return ans;
}

int diff(int order[], int j, int x) {
    int i = order[j];
    int ans = - s[j][i] + s[j][x];

    int tmp = sum[x];
    exist[x][j] = 1;
    make_sum(x);
    ans -= c[x]*(sum[x]-tmp);
    sum[x]=tmp;
    exist[x].erase(j);

    tmp = sum[i];
    exist[i].erase(j);
    make_sum(i);
    ans -= c[i]*(sum[i]-tmp);
    sum[i]=tmp;
    exist[i][j] = 1;

    return ans;
}

int diff_1opt(int order[], int j, int *dif) {
    int max = 0;
    int max_i = order[j];
    rep(i,26) {
        if (i == order[j]) continue;
        int ans = s[j][i];
        int tmp = sum[i];
        exist[i][j] = 1;
        make_sum(i);
        ans -= c[i]*(sum[i]-tmp);
        sum[i]=tmp;
        exist[i].erase(j);

        if (max < ans) {
            max = ans;
            max_i = i;
        }
    }
    *dif = diff(order, j, max_i);
    return max_i;
}

void improve(int order[], int offset, int *j, int *opt, int *dif) {
    int max = -1000000;
    int max_j, max_opt;
    rep(i,d) {
        *j = (offset + i) % d;
        if (iteration - tabu[*j] < 15) continue; // tabu len
        *opt = diff_1opt(order, *j, dif);
        if (*dif > 0) return;
        if (max < *dif) {
            max = *dif;
            max_j = *j;
            max_opt = *opt;
        }
    }
    *j   = max_j;
    *opt = max_opt;
    *dif = max;
}


int main() {
    clock_t start = clock();
    srand(time(NULL));
    cin >> d;
    rep(i,26) cin >> c[i];
    rep(j,d) {
        rep(i,26) cin >> s[j][i];
    }

    int order[d];
    int last[26]; rep(i,26) last[i]=-1;
    rep(j,d) {
        int max=s[j][0], max_i = 0;
        rep(i,26) {
            int score=s[j][i]+ c[i] * (j-last[i]);
            if (max < score) {
                max = score;
                max_i = i;
            }
        }
        order[j] = max_i;
        last[max_i] = j;
        //cout << (max_i+1) << endl;
    }
    sol_init(order);
    //cout << sol_val(order) << endl;

    int best_val = sol_val(order);
    int best_order[d]; memcpy(best_order, order, sizeof(int)*d);
    int last_j = rand()%d, j=(last_j+1)%d;
    while (j!=last_j) {
        clock_t now = clock();
        if ((double)(now - start)/CLOCKS_PER_SEC > 1.9) break;
        int dif, opt;
        improve(order, j, &j, &opt, &dif);
        tabu[j] = iteration++;
        order[j]=opt;
        sol_init(order);
        //printf("%3d (%2d) = %d\n", j, opt+1, sol_val(order));

        if (best_val < sol_val(order)) {
            best_val = sol_val(order);
            memcpy(best_order, order, sizeof(int)*d);
            //cout << best_val << endl;
        }
        last_j = j;
        j=(j+1)%d;
    }
    for (auto x:best_order) cout << (x+1) << endl;
    //cout << best_val << endl;
}


Measured memory_bytes: 3736