#include "bits/stdc++.h"

using namespace std;

#define rep(loop, N) for (int loop = 0; loop < N; loop++)

struct Node {
	Node* parent = NULL;
	vector<Node*> child;
	long long value = 0;
};
struct Edge {
	int parent = 0;
	int child = 0;
	bool operator <(const Edge& right) const { return parent < right.parent; }
};
struct Tree {
	vector<Node> node;
	Tree(int, vector<Edge>);
};
Tree::Tree(int nodeNum, vector<Edge> edge) {
	node.resize(nodeNum);
	for (Edge& it : edge) {
		node[it.child].parent = &node[it.parent];
		node[it.parent].child.push_back(&node[it.child]);
	}
}

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
		else {
			break;
		}
	}
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

long long gcd(long long num1, long long num2) {
	return (num2 == 0 ? num1 : gcd(num2, num1 % num2));
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	long long m_module = 1000000007;
	vector<struct Memo> memo;
public:
	long long calculate(int, int);
	Combination1(int, long long);
};
long long Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, long long module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if ((index == (int)sequence.size() - 1 && sequence[index] == size - 1)
		|| (index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1)) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

struct Contest { vector<int> s; int c = 0; int last = -1; };

struct Project {
	array<Contest, 26> contest;
	int todays_score(int d, int contest_index);
	Project(int D) {
		rep(i,26) contest[i].s.resize(D);
		rep(i, 26) cin >> contest[i].c;
		rep(i, D) rep(j, 26) cin >> contest[j].s[i];
	}
};

int Project::todays_score(int d, int contest_index) {
	int score = contest[contest_index].s[d];
	for (int i = 0; i < 26; i++) {
		if(i != contest_index) score -= contest[i].c * (d - contest[i].last);
	}
	return score;
}

struct Schedule {
	vector<int> schedule;
	Schedule(int D) { schedule.resize(D); }
	int d_score(const Project& prj, int d, int q);
	int& operator[](int index) { return schedule[index]; }
};

int Schedule::d_score(const Project& prj, int d, int q) {

	int D = (int)schedule.size();
	int def = prj.contest[q].s[d] - prj.contest[schedule[d]].s[d];
	int i;

	for (i = d - 1; i >= 0; i--) {
		if (schedule[i] == schedule[d]) break;
	}
	int j;
	for (j = d + 1; j < D; j++) {
		if (schedule[j] == schedule[d]) break;
	}
	j--;
	def -= prj.contest[schedule[d]].c * (j - d + 1) * (d - i);

	for (i = d - 1; i >= 0; i--) {
		if (schedule[i] == q) break;
	}
	for (j = d + 1; j < D; j++) {
		if (schedule[j] == q) break;
	}
	j--;
	def += prj.contest[q].c * (j - d + 1) * (d - i);
	return def;
}

void A_AtCoder_Contest_Scheduling(void) {

	constexpr int num = 100000;

	int D; cin >> D;
	Project prj(D);
	
	Schedule schedule(D);

	int S = 0;
	rep(d, D) {
		int max_score = prj.todays_score(d, 0);
		int max_index = 0;
		for (int i = 1; i < 26; i++) {
			int score = prj.todays_score(d, i);
			if (score > max_score) {
				max_score = score;
				max_index = i;
			}
		}
		S += max_score;
		prj.contest[max_index].last = d;
		schedule[d] = max_index;
	}

	srand(time(NULL));
	rep(i, num) {
		int r_d = rand() % D;
		int r_q = rand() % 26;
		int def = schedule.d_score(prj, r_d, r_q);
		if (def > 0) {
			schedule[r_d] = r_q;
		}
	}

	rep(i, D) {
		cout << schedule[i] + 1 << endl;
	}
}

void B_Scoring(void) {

	int D; cin >> D;
	Project prj(D);
	
	vector<int> t(D);
	rep(i, D) {
		cin >> t[i];
		t[i]--;
	}

	int S = 0;
	rep(d, D) {
		S += prj.todays_score(d, t[d]);
		prj.contest[t[d]].last = d;
		cout << S << endl;
	}

	return;
}

void C_Incremental_Scoring(void) {
	
	int D; cin >> D;
	Project prj(D);
	Schedule t(D);
	rep(i, D) {
		cin >> t[i];
		t[i]--;
	}

	int S = 0;
	rep(d, D) {
		S += prj.todays_score(d, t[d]);
		prj.contest[t[d]].last = d;
	}

	int M; cin >> M;
	vector<int> d(M), q(M);
	rep(i, M) {
		cin >> d[i]; cin >> q[i]; d[i]--; q[i]--;
	}
	rep(i, M) {
		S += t.d_score(prj, d[i], q[i]);
		t[d[i]] = q[i];
		cout << S << endl;
	}
	return;
}

int main(void) {

	cout << fixed << setprecision(15);
	A_AtCoder_Contest_Scheduling();
	//B_Scoring();
	//C_Incremental_Scoring();
	return 0;
}


Measured memory_bytes: 3668