/* Aa^~ kokoro ga pyonpyon suru n jaa^~
// ZZZXXkXkkkZ!``` ``` ``` ``` ``` ``` ``` ``` ``` ``` ``` ```?Wfpppbpbbpbbpbbbkbkk
// ppbbbpbbpVr`` `` ` ` ` ` ```` `` ` ` ``  ` ` ` ` ` ` ` ` `  dppbbkkkkkkkkkkqkqkk
// HkqqqqqkkWr`` ` ` ``` ``` `?G, ` ` ``.JC!```` ` ` `` `` ````(Wpbkkkkkkkkqkkkkkqk
// mmmmmqqqqpr` `` `` ```````.+zT=`` `` 7TO-.```````` `` `` ```(yppbkkkkkkkkkkkkkkk
// ggmgmmqqqH$ ``````````....````` `  ````````.`````` `` ``````.yfpppbbbbkkkkqqqqqH
// gmmmmmqqqkW<```` `````...`````  .,.`  ````....````` ``````` (Wbqqmgmmgmggggggggg
// qmmmqqqqkkWk.``````````````````` ;:<`` `````.`````````````-_<-?WHHqmmmmmmgmmgggg
// @@@@@@@gggHH6- ``````````````` `` _ `` ```````````````` ._~~_.`-?Wkqmmmmmmmggg@g
// @@@@g@gggHY~.-<_- `````````````````````````````````` ._~~(<-``.`.(WHqqqmmggggmmm
// @@g@gggHH=.`..._<-___..```````````````````````. .-_~~~_(!``-.``.`` OHHWUWHmqHWXW
// gggggmqK1.``..~.. _<<+-(____..  ````````  ..__~~_((<<!.`.``` .``.`` j0C1XUHmHIdW
// ggmmqH0!,_``.>`````` _<<;<v<<<++((((((((((<<<<<<~_. (-.``~``.>..```  jOuWHHqHIdH
// gmmqkW!`(_ J>`    `` ` _~<`_~~~~<<<<<<<~~__````````` ?1. ._`(__```    zXWHg@HkXH
// gHHWS{``(lJ<!``.``.```(:+>`._`````.` <..`` - ``. `   _ ?&._.I`_`````` .XyVfppppW
// HHHSv``.(X:_..... _..(;+<!.(<..-.....-.-_..+_`..<.`.`..`_IJd}  .`..````jqg@@@@@@
// XHWZ{..<Jk~!.`.. (<.-(+>(_.(1.(_..`.`.`.<_.+<_..<<-..._..-zy>.`_`...```.WH@HHHHH
// bkWt~.-jCz(_..`.(+<.(;< ._-<=_(<_..-....(_.<1<..(<<.`._..-JUS-._.`...```dHmH9VUH
// WUUO..(f.(c...__+z<-(+~` _-+<_(><..__.`.(<._.z_.(1;_..__.(C(zT-(..`...``(WHR<+Xk
// kkkk._(_.->..._(z;:_><.._>_+_<(1>_._<...(v<<.(<.(+z<..-_(Z~_<_j+_..`...`(WHKz1ZW
// @@gR._+_..~..-<+z<<?<>```_.<_.(+1><_;_..(1_:`.<<??1z--(+Z!..<_.j<....`..(bgHAAQX
// @@mR.(j:..~.._<z!`.(>~``` ~(_.(+<1><><_.(((_`.<__`.<_.(X>...<_.(<.....`.JUWWWyWW
// @gmH_(zl..(.._+>```<+_````.~>``(+.<?>>_._(<```(<<``(__<>....<.._<.......dXkkkHHH
// mmqHl(dk_.(_.-=~`.`.1-..._~-1.``_:`(??<_~(`.--.&_.`.<(;<...._.._<..`..._Xg@@@@@@
// qHkpk(dX<.(;..j_```.(((JJ&a&-~``````.1<_```-(((e+.-(/`(>...._..(<......(Wmggg@@g
// HVHbWcz><__+_.(_.(dWWHHH@HHc~````````.+~`` (jHMMMHHHm&.?..._<..(<_..._.(WqqHHmHg
// 0>vWWkzZwl~<o.__`__~X@@HM@Hb ```.`.``. ```` d@@HHH@@K?76...(<..(<_...(_(ppWWWWHq
// X0XWHKXXw$<(z<.( `` WHHMHHHH_``````````````.WHHMNMHHH_`(...(<_.(z_..._<(fWVC174W
// XuXWHHWWz>__+z+.!`..??CZYCOX_`````````````.`~.OvTUZUS_`~.._+?_.(_~_.._zjO=1+~+jy
// kkkkkkkkX:._<z=1(_`` << ``->``.``.``.``.```` ?<`` (v!`._..(??_.(1._.._=dUOOzzzwX
// @@@@@@@@H<...1O=v<_...__ -_````````````````.`` `` ~.`` :.~+=?~.(;_(...jdQQQQQkkk
// H@@@@@@@H~...(==>.~~~~~....`.`````````.`````.`........->.(===~~<<.(...(dg@@@@@@@
// @@@H@@HHH_.__(=l>~.~~~~~....``.``.``.```..`......~~~~~(<_+=l=~_<.->..~_dqggggg@g
// @H@@@@MHH_._<(=l>...........```````````````.`...~~~~~~+<(=lz=~((j=z_..~jWqmmgggm
// @@H@@HHWH_._<(lll-.......```.````.``.`..`````........_z<+llZz~(lOO=<...(VYUUUW9Y
// @@HMMHWZf>~_=:=llw+.`````````.`.```__~~_``.`````.....(z+llOOz_zllOlz~..~<<1+dW>_
// MMM#MHHWXl~_=>1ltwOl&.`.``.`````.``````````````.````.(llttwtz(OltwOz<..__zwOwwOz
// HM#HMHUUI<._1z+ttOZttlt&....``.``.`.````.``...``...(zZtttOktzjttttwlz_._<(Xkkkkk
// HHHmHSZu:(_~+OztttXtttOZZttO+-..............-(+ztOttwttttd0tOZttttwOl<~.(_dMMHHH
// rvuuXuuI~~<~(uttttwvOwwwkQQHMMHHHHHHHHHMMMNmgey?OwwwrtttwXOtwttttttXtO-~.((wZyyy
// HHHHHHK>(~(-(dOrtrrl(QgMHMMMHHHHHHHHHHHHHHHH##HMNkX0rrrrXXrd%`` (Ctwwtz_~.<(Wg@H
// NNNNNHD(~(zo~zXrrrQdHHMMNMHHHHHHHHHHHHHHHHHHHHHH##HNmyrdKkwZ ` _``-zwrt1~~_<(MNM
// MMMMM#<<_jwr:(Z4QHHMMHMHHHHHHHHHHHHHHHHHHHHHHHHHHHH###NHSXZ>` ~````.OXtt>~._<?MM
*/

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cerr << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}

#ifdef PYONPOI
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cerr<<endl; \
  }while(0)
#else
#define DEBUG
#endif
void init_io(int argc, char* argv[]){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
#ifdef PYONPOI
  if(argc > 1) {
    ifstream *ifs = new ifstream();
    ifs->open(argv[1]);
    cin.rdbuf(ifs->rdbuf());
  }
#endif
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

const int NUM = 26;

uint32_t xor64(void) {
  static uint64_t x = 88172645463325252ULL;
  x = x ^ (x << 13); x = x ^ (x >> 7);
  return x = x ^ (x << 17);
}

// chrono
struct Timer{
  chrono::system_clock::time_point start;
  int mLim;
  Timer(){
	start = chrono::system_clock::now();
  }

  void SetLimit(int lim){
	mLim = lim;
  }

  // milli seconds
  bool TLE(int lim = -1) const{
	if(lim < 0) lim = mLim;
	auto crt = chrono::system_clock::now();
	return chrono::duration_cast<chrono::milliseconds>(crt - start).count() > lim;
  }
};



struct Task {
  int D;
  VI cost;
  VVI gain;
};

struct Sched {
  VI id;
  int score;

  void set_score(const Task& task, int D = -1) {
    if (D <= 0) D = task.D;

    int res = 0;
    VI last(NUM);
    REP(i,D){
      int contest = id[i];
      res += task.gain[i][contest];
      last[contest] = i+1;

      REP(j,NUM) res -= task.cost[j] * (i+1 - last[j]);
    }

    score = res;
  }

  void modify(const Task& task, int day, int new_cont) {
    int prev_cont = id[day];
    if (prev_cont == new_cont) return;

    auto calc = [&](int cont) {
      int last = 0;
      int delta = 0;
      REP(d,task.D){
        if (id[d] == cont) {
          last = d + 1;
          delta += task.gain[d][cont];
        }
        delta -= task.cost[cont] * (d+1 - last);
      }
      return delta;
    };

    score -= calc(prev_cont) + calc(new_cont);

    id[day] = new_cont;
    score += calc(prev_cont) + calc(new_cont);
  }
};

#define PROB_B 0

Task input(){
  Task task;
  cin >> task.D;

  task.cost.resize(NUM);
  cin >> task.cost;

  task.gain= VVI(task.D, VI(NUM));
  cin >> task.gain;

  return task;
}

void output(const Sched& sched) {
  for(auto id : sched.id) cout << id+1 << endl;
}

int calc_score(const Task& task, Sched& sched, int D = 0){
  sched.set_score(task, D);
  return sched.score;
}

Sched solve_greedy(const Task& task) {
  Sched sched;
  sched.id.resize(task.D);

  REP(d,task.D){
    int best_cont = 0;
    int best_score = -1e9;
    REP(i,NUM) {
      sched.id[d] = i;
      auto score = calc_score(task, sched, d+1);
      if (score > best_score){
        best_score = score;
        best_cont = i;
      }
    }

    sched.id[d] = best_cont;
  }

  return sched;
}

Sched solve_greedy2(const Task& task) {
  Sched sched;
  sched.id.resize(task.D);

  REP(d,task.D){
    int best_cont = 0;
    int best = -1e9;
    REP(i,NUM) {
      if (task.gain[d][i] > best) {
        best = task.gain[d][i];
        best_cont = i;        
      }
    }

    sched.id[d] = best_cont;
  }

  return sched;
}

/*
counter=429681, sched.score=654340
*/
bool prob(int crt, int nxt, int t) {
  const double MAX_T = 5e6;
  const double SCALE = 1e-3;
  const int DENUM = 1e6;
  double temp = (MAX_T - min(MAX_T, 1.*t)) / MAX_T;
  int lb = DENUM * exp((nxt - crt) * SCALE / (temp * temp));

  return rand() % DENUM < lb;
}

Sched solve(const Task& task) {
  Timer timer;
  auto sched = solve_greedy(task);
  sched.set_score(task);

  Sched best_sched = sched;
  int best_score = sched.score;

  int counter = 0;
  while(!timer.TLE(1500)) {
    int type = xor64() % 16;
    if (type < 12) {
      int day = xor64() % task.D;
      int new_cont = xor64() % NUM;
      int prev_cont = sched.id[day];

      if(new_cont == prev_cont) continue;
      int prev_score = sched.score;

      sched.modify(task, day, new_cont);
      if (best_score < sched.score){
        best_score = sched.score;
        best_sched = sched;
      }

      if (prev_score > sched.score) {
        if (!prob(prev_score, sched.score, counter)) {
          sched.modify(task, day, prev_cont);
        }
      }
      ++counter;
    }
    else {
      int new_day = xor64() % task.D;
      int prev_day = xor64() % task.D;
      int new_cont = sched.id[new_day];
      int prev_cont = sched.id[prev_day];

      if(new_day == prev_day) continue;
      int prev_score = sched.score;

      sched.modify(task, prev_day, new_cont);
      sched.modify(task, new_day, prev_cont);
      if (best_score < sched.score){
        best_score = sched.score;
        best_sched = sched;
      }

      if (prev_score > sched.score) {
        if (!prob(prev_score, sched.score, counter)) {
          sched.modify(task, prev_day, prev_cont);
          sched.modify(task, new_day, new_cont);
        }
      }
      ++counter;
    }
  }

  sched = best_sched;
#ifdef PYONPOI
  DEBUG(counter, sched.score);
#endif

  return sched;
}


int main(int argc, char* argv[]){
  init_io(argc, argv);

  auto task = input();

#if PROB_B
  {
    Sched sched;
    sched.id.resize(task.D);
    cin >> sched.id;
    for(auto& id: sched.id) --id;

    sched.set_score(task);

    int M;
    cin >> M;
    while(M--){
      int d, q;
      cin >> d >> q;
      sched.modify(task, d-1, q-1);
      cout << sched.score << endl;
    }
    return 0;
  }
#endif

  auto sched = solve(task);
  output(sched);

  return 0;
}



Measured memory_bytes: 4316