#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
#include <queue>
#include <cmath>
#include <iomanip>
#include <array>
#include <string>
#include <stack>
#include <cassert>
#include <memory>
#include <random>

struct ContestSpan {
	int i, c, prev, next;
	int penalty() const {
		return (c * (next - prev - 1) * (next - prev)) >> 1;
	}
	bool operator<(const ContestSpan& that) const {
		return penalty() < that.penalty();
	}
};
int main() {
	int d; std::cin >> d;
	std::vector<int> c(26); for (auto& ci : c) std::cin >> ci;
	std::vector<std::vector<int>> s(d, std::vector<int>(26));
	for (auto& line : s) {
		for (auto& si : line) std::cin >> si;
	}
	std::vector<int> contest(d);
	std::priority_queue<ContestSpan> queue;
	std::vector<std::set<int>> days(26, std::set<int>{-1});
	for (auto i = 0; i < d; ++i) {
		std::vector<int> indices(26); std::iota(indices.begin(), indices.end(), 0);
		std::sort(indices.rbegin(), indices.rend(), [&s, i](const int a, const int b) {return s[i][a] < s[i][b]; });
		contest[i] = indices[0];
		queue.push(ContestSpan{ indices[0], c[indices[0]], *days[indices[0]].rbegin(), i });
		days[indices[0]].insert(i);
	}
	for (auto i = 0; i < 26; ++i) {
		queue.push(ContestSpan{ i, c[i], *days[i].rbegin(), d });
		days[i].insert(d);
	}
	const auto change_contest = [&](const int day, const ContestSpan new_contest) {
		const auto current_contest = contest[day];
		const auto new_next = *days[current_contest].lower_bound(day);
		const auto new_prev = *std::prev(days[current_contest].lower_bound(day));
		const auto new_span = ContestSpan{ current_contest, c[current_contest], new_prev, new_next };
		const auto prev = ContestSpan{ new_contest.i, new_contest.c, new_contest.prev, day };
		const auto next = ContestSpan{ new_contest.i, new_contest.c, day, new_contest.next };
		contest[day] = new_contest.i;
		queue.push(new_span); queue.push(prev); queue.push(next);
		return new_span;
	};
	while (!queue.empty()) {
		const auto span = queue.top(); queue.pop();
		if ((span.prev < 0 || contest[span.prev] == span.i) && (span.next >= d || contest[span.next] == span.i)) continue;
		if (*std::prev(days[span.i].lower_bound(span.next)) != span.prev) continue;
		const auto penalty = span.penalty();
		const auto day = span.next - span.prev;
		int suspect = -1;
		int suspect2 = -1;
		int gain = 0;
		for (auto mid = span.prev + 1; mid < span.next; ++mid) {
			const auto current_contest = contest[mid];
			const auto new_next = *days[current_contest].lower_bound(mid);
			const auto new_prev = *std::prev(days[current_contest].lower_bound(mid));
			const auto new_span = ContestSpan{ current_contest, c[current_contest], new_prev, new_next };
			int min_pos = -1;
			int min_gain = 0;
			for (auto mid2 = new_span.prev + 1; mid2 < new_span.next; ++mid2) {
				const auto current_contest2 = contest[mid2];
				if (current_contest2 == span.i) continue;
				const auto new_next2 = *days[current_contest2].lower_bound(mid2);
				const auto new_prev2 = *std::prev(days[current_contest2].lower_bound(mid2));
				const auto new_span2 = ContestSpan{ current_contest2, c[current_contest2], new_prev2, new_next2 };
				const auto prev = ContestSpan{ new_span.i, new_span.c, new_span.prev, mid2 };
				const auto next = ContestSpan{ new_span.i , new_span.c, mid2, new_span.next };
				const auto new_pen = prev.penalty() + next.penalty() + new_span2.penalty();
				const auto current_sat = s[mid2][current_contest2];
				const auto new_sat = s[mid2][new_span.i];
				const auto new_gain = new_sat - new_pen - current_sat + penalty;
				if (new_gain > min_gain) {
					min_pos = current_contest2;
					min_gain = new_gain;
				}
			}
			const auto prev = ContestSpan{ span.i, span.c, span.prev, mid };
			const auto next = ContestSpan{ span.i, span.c, mid, span.next };
			const auto new_pen = prev.penalty() + next.penalty() + new_span.penalty();
			const auto current_sat = s[mid][current_contest];
			const auto new_sat = s[mid][span.i];
			const auto new_gain = new_sat - new_pen - current_sat + penalty + min_gain;
			if (new_gain > gain) {
				suspect = mid;
				gain = new_gain;
				suspect2 = min_pos;
			}
		}
		if (suspect < 0) {
			continue;
		}
		const auto new_span = change_contest(suspect, span);
		if (suspect2 < 0) {
			continue;
		}
		change_contest(suspect2, new_span);
	}
	for (const auto i : contest) {
		std::cout << i + 1 << '\n';
	}
}

Measured memory_bytes: 3716