# pragma GCC optimize "O3,omit-frame-pointer,inline"
#define _LOCAL
#define _DEBUG
#define _DEBUG2
#define _DEBUG3
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include "bits/stdc++.h"
#include <sys/time.h>
#include <emmintrin.h>
#include <string>
#include <bitset>
#include <unistd.h>

using namespace std;

inline long long GetTSC() {
  long long lo, hi;
  asm volatile ("rdtsc": "=a"(lo), "=d"(hi));
  return lo + (hi << 32);
}
inline double GetSeconds() {
  return GetTSC() / 3.0e9;
}

struct XorShift {
  uint64_t x = 88172645463325252ULL;
  double nl[65536];
  XorShift() {}

  void init(){
    double n2 = 1.0 / 65536*2;
    for(int i=0; i<65536; i++) nl[i] = log(i / 65536.0 + n2);
  }

  void setSeed(uint64_t seed) { x = seed; init(); }

  uint64_t next() {
    x ^= x << 13; x ^= x >> 7; x ^= x << 17;
    return x;
  }

  int nextInt(int n) {
    return next() % n;
  }

  double nextDouble() {
    uint64_t v = next() >> 11; // 53bit
    return (double)v / (1ULL << 53);
  }

  double nextLog() {
    return nl[nextInt(65536)];
  }
};


XorShift xs;
const double TO = 1.98;

double starttime, gt;
int ttt,ctt,dtt,ett,ftt,gtt,htt;

const int D = 365;
const int M = 26;
int C[M];
int S[D][M];
int T[D];
int mems[D+1][D];

struct Link{
  int day, c;
  Link *prev;
  Link *next;

  Link() {}
};

Link LA[D + M*2];
int PS[M][D+1];
int DS[D+2];

void init(){
  int d;
  cin >> d;
  for(int i=0; i<M; i++) cin >> C[i];
  for(int i=0; i<D; i++) for(int j=0; j<M; j++) cin >> S[i][j];

  for(int i=0; i<D+2; i++) DS[i] = (i-1) * i / 2;

  for(int i=0; i<M; i++){
    LA[D+i].day = -1;
    LA[D+i].next = &LA[D+M+i];
    LA[D+i].c = i;
    LA[D+M+i].day = D;
    LA[D+M+i].prev = &LA[D+i];
    LA[D+M+i].c = i;
  }

  int cc[M] = {};
  for(int i=0; i<D; i++){
    int c = 0;
    double mm = -1e7;
    for(int j=0; j<M; j++){
      int k = (D + cc[j]) / (cc[j] + 1);
      double t = (C[j] + 0.5) * DS[k] * k;
      if(mm < t){
        mm = t;
        c = j;
      }
    }
    cc[c]++;
    auto& ld = LA[D+M+c];
    auto& lp = *ld.prev;
    auto& li = LA[i];
    li.day = i;
    li.prev = ld.prev;
    li.c = c;
    li.next = &ld;
    ld.prev = &li;
    lp.next = &li;
  }

  for(int i=0; i<M; i++){
    int pd = -1;
    for(int j=0; j<D; j++){
      PS[i][j] = pd;
      if(LA[j].c == i){
        pd = j;
      }
    }
  }

  for(int i=0; i<D; i++) for(int j=0; j<D; j++) mems[i][j] = i - 1;

  cerr << "init_time: " << GetSeconds() - starttime << endl;
}

int score(){
  int res = 0;

  for(int i=0; i<M; i++){
    auto l = LA[D+i].next;
    int pd = -1;
    while(1){
      res -= C[l->c] * DS[l->day - pd];
      if(l->day == D) break;
      res += S[l->day][l->c];
      pd = l->day;
      l = l->next;
    }
  }

  return res;
}

inline int swapScore(const Link la, int db){
  const int da = la.day;
  const int pda = la.prev->day;
  const int nda = la.next->day;
  const int ca = la.c;

  return S[db][ca] - S[da][ca]
    - C[ca] * ((DS[db - pda] + DS[nda - db]) - (DS[da - pda] + DS[nda - da]));
}

inline void swapPs(const Link la, int db){
  const int ca = la.c;
  const int da = la.day;
  const int pda = la.prev->day;
  const int nda = min(la.next->day, D-1);
  if(da < db) memcpy(PS[ca] + (da + 1), mems[pda + 1], sizeof(int) * (db - da));
  if(db < nda) memcpy(PS[ca] + (db + 1), mems[db + 1], sizeof(int) * (nda - db));
}

inline void swapLa(Link& la, Link& lb){
  swap(la.day, lb.day);
  swap(LA[la.day], LA[lb.day]);
  swap(la.prev->next, lb.prev->next);
  swap(la.next->prev, lb.next->prev);
}

inline void swap2(Link& la, Link& lb){
  swapPs(la, lb.day);
  swapPs(lb, la.day);
  swapLa(la, lb);
}

inline void swap3(Link& la, Link& lb, Link& lc){
  swapPs(la, lb.day);
  swapPs(lb, lc.day);
  swapPs(lc, la.day);
  swapLa(la, lb);
  swapLa(la, lc);
}

inline void swap4(Link& la, Link& lb, Link& lc, Link& ld){
  swapPs(la, lb.day);
  swapPs(lb, lc.day);
  swapPs(lc, ld.day);
  swapPs(ld, la.day);
  swapLa(la, lb);
  swapLa(la, lc);
  swapLa(la, ld);
}

inline void swap5(Link& la, Link& lb, Link& lc, Link& ld, Link& le){
  swapPs(la, lb.day);
  swapPs(lb, lc.day);
  swapPs(lc, ld.day);
  swapPs(ld, le.day);
  swapPs(le, la.day);
  swapLa(la, lb);
  swapLa(la, lc);
  swapLa(la, ld);
  swapLa(la, le);
}

void solve(){
  int ms = score();

  const double gg = 1400;

  while(1){
    gt = (TO - (GetSeconds() - starttime)) / TO;
    if(gt <= 0) break;

    for(int tt=0; tt<D; tt++){
      int da = tt;
      auto& la = LA[da];
      int ca = la.c;
      int cc = xs.nextInt(M-1);
      if(cc >= ca) cc++;
      Link* lc;
      if(PS[cc][da] < 0){
        lc = &LA[D + cc];
      }else{
        lc = &LA[PS[cc][da]];
      }
      int pda = la.prev->day;
      int pdc = lc->day;
      int nda = la.next->day;
      int ndc = lc->next->day;

      int ts = S[da][cc] - S[da][ca]
        - C[ca] * (DS[nda - pda] - DS[da - pda] - DS[nda - da])
        - C[cc] * (DS[da - pdc] + DS[ndc - da] - DS[ndc - pdc]);

      if(ts >= 0 || ts > gg * xs.nextLog() * gt){
        ett++;

        nda = min(nda, D-1);
        ndc = min(ndc, D-1);
        if(da < nda) memcpy(PS[ca] + (da + 1), mems[pda + 1], sizeof(int) * (nda - da));
        if(da < ndc) memcpy(PS[cc] + (da + 1), mems[da + 1], sizeof(int) * (ndc - da));

        la.prev->next = la.next;
        la.next->prev = la.prev;
        la.c = cc;
        la.prev = lc;
        la.next = lc->next;
        lc->next->prev = &LA[da];
        lc->next = &LA[da];

        ms += ts;
      }
    }

    for(int tt=0; tt<D; tt++){
      dtt++;
      int a = tt;
      int bi = LA[a].prev->day + 1;
      int ba = LA[a].next->day - 1;
      if(bi >= ba) continue;
      int b = dtt % (ba - bi) + bi;
      if(b >= a){
        b++;
        if(LA[b].prev->day > a) continue;
      }else{
        if(LA[b].next->day < a) continue;
      }

      ttt++;

      Link& la = LA[a];
      Link& lb = LA[b];
      int tsa = swapScore(la, b);
      int ts = tsa + swapScore(lb, a);
      if(ts >= 0 || ts > gg * xs.nextLog() * gt){
        ctt++;
        swap2(la, lb);
        ms += ts;
      }else if(ba - bi > 2){
        int ci = max(bi, lb.prev->day + 1);
        int ca = min(ba, lb.next->day - 1);
        if(ci >= ca - 2) continue;
        int c = xs.nextInt(ca - ci - 2) + ci;
        if(b >= a){
          if(c >= a){
            c++;
            if(c >= b) c++;
          }
          if(LA[c].prev->day > a || LA[c].next->day < b) continue;
        }else{
          if(c >= b){
            c++;
            if(c >= a) c++;
          }
          if(LA[c].prev->day > b || LA[c].next->day < a) continue;
        }

        Link& lc = LA[c];

        int tsb = tsa + swapScore(lb, c);
        int ts = tsb + swapScore(lc, a);
        if(ts >= 0 || ts > gg * xs.nextLog() * gt){
          ftt++;
          swap3(la, lb, lc);
          ms += ts;
        }else if(tsb >= 0 && ca - ci > 3){
          int di = max(ci, lc.prev->day + 1);
          int da = min(ca, lc.next->day - 1);
          if(di >= da - 3) continue;
          int d = xs.nextInt(da - di - 3) + di;
          int mi = min(min(a, b), c);
          int ma = max(max(a, b), c);
          int md = a + b + c - mi - ma;
          if(d >= mi){
            d++;
            if(d >= md){
              d++;
              if(d >= ma){
                d++;
              }
            }
          }
          if(LA[d].prev->day > mi || LA[d].next->day < ma) continue;

          Link& ld = LA[d];
          int tsc = tsb + swapScore(lc, d);
          int ts = tsc + swapScore(ld, a);
          if(ts >= 0 || ts > gg * xs.nextLog() * gt){
            gtt++;
            swap4(la, lb, lc, ld);
            ms += ts;
          }else if(tsc >= 0 && da - di > 4){
            int ei = max(di, ld.prev->day + 1);
            int ea = min(da, ld.next->day - 1);
            if(ei >= ea - 4) continue;
            int e = xs.nextInt(ea - ei - 3) + ei;
            if(e >= mi){
              e++;
              if(e >= md){
                e++;
                if(e >= ma) e++;
              }
            }
            if(e == d || LA[e].prev->day > min(d, mi) || LA[e].next->day < max(d, ma)) continue;

            Link& le = LA[e];
            int ts = tsc + swapScore(ld, e) + swapScore(le, a);
            if(ts >= 0 || ts > gg * xs.nextLog() * gt){
              htt++;
              swap5(la, lb, lc, ld, le);
              ms += ts;
            }
          }
        }
      }
    }
  }

  cerr << "ms: " << ms << " time: " << GetSeconds() - starttime;
  cerr << " ttt: " << ttt << " ctt: " << ctt << " dtt: " << dtt;
  cerr << " ett: " << ett << " ftt: " << ftt << " gtt: " << gtt;
  cerr << " htt: " << htt << endl;
}

void output(){
  for(int i=0; i<D; i++) T[LA[i].day] = LA[i].c;
  for(int i=0; i<D; i++) cout << T[i] + 1 << endl;
}

int main(){
  starttime = GetSeconds();
  srand((unsigned) time(NULL));
  xs.setSeed(rand() % 65536 + 65537);
  cerr << "seed: " << xs.x << endl;
  init();
  solve();
  output();

  return 0;
}


Measured memory_bytes: 5244