/**
*    author:  boutarou
*    created: 28.06.2020 20:54:48
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define fcout cout << fixed << setprecision(15)
using lint = long long;
using P = pair<int, int>;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

const double PI = 3.1415926535897932;
const int INF = 1e9;

int d;
int c[26];
int s[365][26];
vector<int> previous(26);

int score(int day, int contest, vector<int> before) {
    int cnt = 0;
    cnt += s[day][contest];
    before[contest] = day;
    rep(i, 26) {
        cnt -= c[i] * (day - before[i]);
    }
    return cnt;
}

int score2(int day, int contest1, int contest2, vector<int> before) {
    int cnt = 0;
    cnt += s[day][contest1];
    before[contest1] = day;
    rep(i, 26) {
        cnt -= c[i] * (day - before[i]);
    }
    day++;
    cnt += s[day][contest2];
    before[contest2] = day;
    rep(i, 26) {
        cnt -= c[i] * (day - before[i]);
    }
    return cnt;
}

int score3(int day, int contest1, int contest2, int contest3, vector<int> before) {
    int cnt = 0;
    cnt += s[day][contest1];
    before[contest1] = day;
    rep(i, 26) {
        cnt -= c[i] * (day - before[i]);
    }
    day++;
    cnt += s[day][contest2];
    before[contest2] = day;
    rep(i, 26) {
        cnt -= c[i] * (day - before[i]);
    }
    day++;
    cnt += s[day][contest3];
    before[contest3] = day;
    rep(i, 26) {
        cnt -= c[i] * (day - before[i]);
    }
    return cnt;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> d;
    rep(i, 26) cin >> c[i];
    rep(i, d) {
        rep(j, 26) cin >> s[i][j];
    }

    rep(i, 26) previous[i] = -1;

    int now = 0;
    for (int i = 0; i + 2 < d; i += 3) {
        int ma = -INF;
        rep(j, 26) {
            rep(k, 26) {
                rep(l, 26) {
                    ma = max(ma, score3(i, j, k, l, previous));
                }
            }
        }
        rep(j, 26) {
            rep(k, 26) {
                rep(l, 26) {
                    if (ma == score3(i, j, k, l, previous)) {
                        cout << j + 1 << endl;
                        cout << k + 1 << endl;
                        cout << l + 1 << endl;
                        now += score3(i, j, k, l, previous);
                        previous[j] = i;
                        previous[k] = i + 1;
                        previous[l] = i + 2;
                        goto bou;
                    }
                }
            }
        }
        bou:;
    }
    if (d % 3 == 2) {
        int i = d - 2;
        int ma = -INF;
        rep(j, 26) {
            rep(k, 26) {
                ma = max(ma, score2(i, j, k, previous));
            }
        }
        rep(j, 26) {
            rep(k, 26) {
                if (ma == score2(i, j, k, previous)) {
                    cout << j + 1 << endl;
                    cout << k + 1 << endl;
                    now += score2(i, j, k, previous);
                    previous[j] = i;
                    previous[k] = i + 1;
                }
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 3692