#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
#include <ctime>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()



unsigned int xor128() {
	static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	unsigned int t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
}

double uniform() {
	return (double)xor128() / ~0u;
}




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



vector<int> greedy() {
	vector<int> ret;
	int last[26] = {};
	rep(i, 26)last[i] = -1;

	rep(i, D) {
		int ma = -INF;
		int con = -1;

		int pena[26];
		rep(j, 26) {
			pena[j] = c[j] * (i - last[j]);
		}

		rep(j, 26) {
			//int score = s[i][j] + pena[j];
			int score = s[i][j] + 5 * pena[j];
			if (ma < score) {
				ma = score;
				con = j;
			}
		}
		assert(con != -1);

		last[con] = i;
		ret.push_back(con);
	}
	return ret;
}


int64_t calc(const vector<int>& ans) {
	int last[26];
	rep(i, 26)last[i] = -1;
	int64_t score = 0;
	rep(i, D) {
		score += s[i][ans[i]];
		last[ans[i]] = i;
		rep(j, 26) {
			score -= c[j] * (i - last[j]);
		}
	}
	return score;
}

inline int penalty(int day1, int day2) {
	int dur = day2 - day1;
	//return c[contest] * (dur - 1) * dur / 2;
	return  (dur - 1) * dur;
}


uint16_t poplow[1 << 16];
uint16_t pophigh[1 << 16];

inline int prev(uint16_t contests[23], uint32_t day) {
	uint16_t b = contests[day / 16] & ((1 << day % 16) - 1);
	if (b != 0) {
		return (day & ~15) + pophigh[b];
	}
	for (int i = day / 16 - 1; i >= 0; i--) {
		if (contests[i] != 0) {
			return i * 16 + pophigh[contests[i]];
		}
	}

	return -1;
}

inline int next(uint16_t contests[23], uint32_t day) {
	uint16_t b = contests[day / 16] & ~((1 << day % 16) - 1) & ~(1 << day % 16);
	if (b != 0) {
		return (day & ~15) + poplow[b];
	}
	for (int i = day / 16 + 1; i < 23; i++) {
		if (contests[i] != 0) {
			return i * 16 + poplow[contests[i]];
		}
	}
	return D;
}

void bit_on(uint16_t contests[23], uint32_t day) {
	contests[day / 16] |= 1 << day % 16;
}

void bit_off(uint16_t contests[23], uint32_t day) {
	contests[day / 16] &= ~(1 << day % 16);
}

vector<int> annealing() {
	uint16_t contests[26][23 /*ceil(365/16)*/];

	vector<int> best;
	int64_t best_score;

	int64_t score;
	vector<int> con;
	//init by greedy
	{
		memset(contests, 0, sizeof(contests));
		vector<int> v = greedy();
		int last[26];
		memset(last, -1, sizeof(last));
		rep(i, D) {
			bit_on(contests[v[i]], i);
		}
		best = con = v;
		best_score = score = calc(v);
	}

	int cnt = 0;
	clock_t start = clock();
	double temp = 1;
	int max_iterates = 100000000;
	rep(ite, max_iterates) {
		if (ite % 1024 == 0) {
			clock_t now = clock();
			if ((double)(now - start) / CLOCKS_PER_SEC > 1.9)break;
			temp = max(1e-8, 2.0 - (double)(now - start) / CLOCKS_PER_SEC - 0.2);
		}
		cnt++;
		if (xor128() % 128 < 90) { // swap
			uint32_t day1 = xor128() % D;
			int dd = xor128() % 35 - 17;
			if (D <= day1 + dd || (int)day1 + dd < 0)continue;
			uint32_t day2 = day1 + dd;
			int con1 = con[day1];
			int con2 = con[day2];
			if (con1 == con2)continue;

			bit_off(contests[con1], day1);
			bit_off(contests[con2], day2);

			int p1 = prev(contests[con2], day1);
			int p2 = next(contests[con2], day1);
			int p3 = prev(contests[con1], day2);
			int p4 = next(contests[con1], day2);
			int p5 = prev(contests[con1], day1);
			int p6 = next(contests[con1], day1);
			int p7 = prev(contests[con2], day2);
			int p8 = next(contests[con2], day2);

			int score_diff = s[day1][con2] + s[day2][con1] - s[day1][con1] - s[day2][con2]
				+ c[con1] * (
					-penalty(p3, day2)
					- penalty(day2, p4)
					+ penalty(p5, day1)
					+ penalty(day1, p6)
					- penalty(p5, p6)
					+ penalty(p3, p4)
					) / 2
				+ c[con2] * (
					-penalty(p1, day1)
					- penalty(day1, p2)
					+ penalty(p7, day2)
					+ penalty(day2, p8)
					- penalty(p7, p8)
					+ penalty(p1, p2)
					) / 2;

			//if (score_diff > 0 || -score_diff / (temp * temp) / 5000 < uniform()) {
			if (score_diff > 0 || exp2(score_diff / temp / 550) > uniform()) {
				bit_on(contests[con1], day2);
				bit_on(contests[con2], day1);
				score += score_diff;
				swap(con[day1], con[day2]);
				if (best_score < score) {
					best = con;
					best_score = score;
				}
			}
			else {
				bit_on(contests[con1], day1);
				bit_on(contests[con2], day2);
			}
		}
		else { // change
			uint32_t day = xor128() % D;
			int to = xor128() % 26;
			if (con[day] == to)continue;

			int c1prev = prev(contests[con[day]], day);
			int c1next = next(contests[con[day]], day);
			int c2prev = prev(contests[to], day);
			int c2next = next(contests[to], day);

			int score_diff = s[day][to] - s[day][con[day]]
				+ c[con[day]] * (
					-penalty(c1prev, c1next)
					+ penalty(c1prev, day)
					+ penalty(day, c1next)
					) / 2
				+ c[to] * (
					-penalty(c2prev, day)
					- penalty(day, c2next)
					+ penalty(c2prev, c2next)
					) / 2;

			//if (score_diff > 0 || -score_diff / (temp * temp) / 5000 < uniform()) {{
			if (score_diff > 0 || exp2(score_diff / temp / 550) > uniform()) {
				score += score_diff;
				bit_off(contests[con[day]], day);
				bit_on(contests[to], day);
				con[day] = to;
				if (best_score < score) {
					best = con;
					best_score = score;
				}
			}
		}
	}
	//cerr << cnt << endl;
	cerr << best_score << endl;
	//cerr << calc(best) << endl;
	return best;
}


void eval() {
	int n = 50;
	int64_t sc = 0;
	mt19937 mt;
	rep(i, n) {
		D = 365;
		rep(i, 26)c[i] = mt() % 100;
		rep(i, 365)rep(j, 26) s[i][j] = mt() % 20000;
		sc += calc(annealing());
	}
	cerr << sc / (double)n << endl;
}


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

	for (int i = 1; i < (1 << 16); i++) {
		int low, high;
		rep(j, 16) {
			if (i >> j & 1) {
				low = j;
				break;
			}
		}
		rep(j, 16) {
			if (i >> j & 1) {
				high = j;
			}
		}
		poplow[i] = low;
		pophigh[i] = high;
	}

#if defined(_MSC_VER)
	eval();
#else
	cin >> D;
	rep(i, 26)cin >> c[i];
	rep(i, 365)rep(j, 26)cin >> s[i][j];

	vector<int> ans = annealing();
	for (int x : ans) {
		cout << x + 1 << endl;
	}

#endif // #if defined(_MSC_VER)


	return 0;
}


Measured memory_bytes: 4156