#include "bits/stdc++.h"
using namespace std;

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int D, c[27];
int s[366][27];

chrono::steady_clock::time_point program_begin;

double runtime() {
	chrono::steady_clock::time_point program_end = chrono::steady_clock::now();

	return chrono::duration_cast<chrono::microseconds>(program_end - program_begin).count() / 1000000.0;
}

int calc(vector<int> sc) {
	vector<int> last(27, 0);
	int val = 0;
	rep(d, 1, D + 1) {
		val += s[d][sc[d]];
		last[sc[d]] = d;
		rep(i, 1, 27)
			val -= c[i] * (d - last[i]);
	}
	return val;
}

int myrand(int a, int b) {
	return a + rand() % (b - a + 1);
}

void solve() {
	vector<int> ans(366), best_ans(366);
	int best_ans_val = -50000000;
	int cur_val = calc(ans);

	for (int i = 1; i <= 365; i++)
		ans[i] = i % 26 + 1;

	int no_random_best;

	{
		int val = calc(ans);
		no_random_best = val;
		if (val > best_ans_val) {
			best_ans_val = val;
			best_ans = ans;
		}
	}

	double T1 = 0.1;
	double T2 = 1.8;

	auto rng = default_random_engine {};
	
	int best_seq = -50000000, best_random = -50000000;
	int best_greedy = -50000000;

	while (runtime() <= 4 * T1 / 5) {
		int base[27];
		rep(i, 1, 27) base[i] = i;
		shuffle(base + 1, base + 27, rng);
		for (int i = 1; i <= 365; i++)
			ans[i] = base[(i - 1) % 26 + 1];

		int val = calc(ans);
		if (val > best_ans_val) {
			best_ans_val = val;
			best_ans = ans;
		}
		chmax(best_seq, val);
	}
	while (runtime() <= T1) {
		for (int i = 1; i <= 365; i++)
			ans[i] = myrand(1, 26);

		int val = calc(ans);
		if (val > best_ans_val) {
			best_ans_val = val;
			best_ans = ans;
		}
		chmax(best_random, val);
	}
	{
		vector<int> local_ans(366, 0);
		vector<int> last(366, 0);
		for (int i = 1; i <= 365; i++) {
			int best_ans = 1, gain = -5000000;
			for (int j = 1; j <= 26; j++) {
				int this_gain = s[i][j] + 8 * max(0, c[j] * (i - last[j]));
				if (this_gain > gain) {
					gain = this_gain;
					best_ans = j;
				}
			}
			local_ans[i] = best_ans;
			last[best_ans] = i;
		}

		int val = calc(local_ans);
		if (val > best_ans_val) {
			best_ans_val = val;
			best_ans = local_ans;
		}
		chmax(best_greedy, val);
	}
	
	ans = best_ans;
	cur_val = best_ans_val;

	int iterations = 0;
	int init_val = cur_val;

	cerr << endl << endl;
	cerr << "INIT:" << best_ans_val << endl;
	cerr << "Nrand: " << no_random_best << endl;
	cerr << "Best random init: " << best_random << "(" << best_random - no_random_best << ")" << endl;
	cerr << "Best sequential init: " << best_seq << "(" << best_seq - no_random_best << ")" << endl;
	cerr << "Best greedy: " << best_greedy << "(" << best_greedy - no_random_best << ")" << endl;

	while (runtime() <= T2) {
		iterations++;

		vector<int> new_ans = ans;
		int d = myrand(1, 364);

		/*
		int n = 1;
		{
			double prob[27];
			rep(i, 1, 27) prob[i] = pow(1.0 * s[d][i], 15);
			double prob_ps[27];
			rep(i, 1, 27) prob_ps[i] = prob_ps[i - 1] + prob[i];
			double rand_double = 1.0 * rand() / RAND_MAX * prob_ps[26];
			rep(i, 1, 27) {
				if (rand_double <= prob_ps[i]) {
					n = i;
					break;
				}
			}
		}
		*/
		swap(new_ans[d], new_ans[d + 1]);

		int new_val = calc(new_ans);
		
		double base_proc = exp(-50.0 * (runtime() - T1) / (T2 - T1));
		double rand_double = 1.0 * rand() / RAND_MAX;
		bool accept =
			rand_double < base_proc * (1.0 * new_val / best_ans_val);
		
		if (new_val > cur_val || accept) {
			ans = new_ans;
			cur_val = new_val;

			if (chmax(best_ans_val, cur_val)) {
				best_ans_val = cur_val;
				best_ans = ans;
			}
		}
	}

	rep(i, 1, D + 1)
		write(best_ans[i]);

	cerr << "Iterations: " << iterations << endl;
	cerr << "Improvement: " << best_ans_val - init_val << endl;
}

void test() {}

int main(int argc, char *argv[]) {
	//cin.tie(0)->sync_with_stdio(0);
	//cin.exceptions(cin.failbit);

	srand(time(NULL));

	program_begin = chrono::steady_clock::now();

	read(D);
	rep(i, 1, 27) read(c[i]);
	rep(i, 1, D + 1) rep(j, 1, 27) read(s[i][j]);
	
	solve();
}


Measured memory_bytes: 4336