#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")

#include <iostream>
#include <algorithm>

#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <cstring>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>

#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>

#include<memory>

#include <climits>


using namespace std;
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> pli;
typedef pair<double,int> pdi;
typedef pair<long double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

template <class T>
using MINPQ = std::priority_queue<T, vector<T>, greater<T>>; //MINPQ<pii> pq;
template <class T>
using MAXPQ = std::priority_queue<T>;


const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll INFLL = 1LL<<62;
const double EPS = 1e-12;
const ll mod = 1000000000 + 7;
//const ll mod = 998244353;
const int dx4[4] = {0, 0, -1, 1};
const int dy4[4] = {-1, 1, 0, 0};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const long double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) (0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false
#define stand(B, i) (((B>>i) & 1) == 1) ? true : false //Bのi番目のbitが1ならtrue, 0ならfalse

//debug
#define DEBUG

#define DUMPOUT cerr

#ifdef DEBUG
#define dump(...) DUMPOUT<<#__VA_ARGS__<<" :["<<__FUNCTION__<<":"<<__LINE__<<"]"<<endl; DUMPOUT<<"    "; dump_func(__VA_ARGS__)
#else
#define dump(...)
#endif

void dump_func() {DUMPOUT << endl;};

template <class Head, class... Tail> void dump_func(Head&& head, Tail&&... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) == 0) DUMPOUT << " ";
    else DUMPOUT << ", ";
    dump_func(std::move(tail)...);
}

//ostream
template<typename T> ostream& operator << (ostream& os, vector<T>& vec) {
    os << "["; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "]";
    return os;
}

template<typename T, typename U> ostream& operator << (ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}

template<typename T, typename U> ostream& operator << (ostream& os, map<T, U>& map_var) {
    os << "[";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")"; itr++;  if(itr != map_var.end()) os << ", "; itr--;
    }
    os << "]";
    return os;
}

template<typename T> ostream& operator << (ostream& os, set<T>& set_var) {
    os << "[";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr; ++itr; if(itr != set_var.end()) os << ", "; itr--;
    }
    os << "]";
    return os;
}

auto start = std::chrono::system_clock::now();
inline double get_time() {
  auto end = std::chrono::system_clock::now();
  auto dur = end - start;
  double msec = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();
  return msec;
}

double timelimit = 0;
inline bool check_time() {
    auto end = chrono::system_clock::now();
    auto dur = end - start;
    auto msec = chrono::duration_cast<chrono::milliseconds>(dur).count();
    if (msec >= timelimit) return false;
    return true;
}

unsigned long long seed128[4]; //x,y,z,wとして利用
inline void seed(unsigned long long s){
    for(int i=1; i<=4; i++){
        seed128[i-1] = s = 1812433253U * (s^(s>>30)) + i;
    }
}

inline unsigned long long Xor128(){
  unsigned long long t;
  t=(seed128[0]^(seed128[0]<<11));
  seed128[0]=seed128[1];
  seed128[1]=seed128[2];
  seed128[2]=seed128[3];
  seed128[3]=(seed128[3]^(seed128[3]>>19))^(t^(t>>8));
  return seed128[3];
}

constexpr int D = 365;
int c[26];
int s[D+1][26];

int best_score;
short best_ans[D+1];
pair<short, short> best_last[26][D+2];
int cur_score;
short cur_ans[D+1];
pair<short, short> cur_last[26][D+2];

void calc_score(int con, int d, int& score) {
  score += s[d][con];
  rep(i, 26) {
    if (con == i) continue;
    score -= c[i] * (d - best_last[i][d-1].fi);
  }
}

void read() {
  int tmp;
  cin >> tmp;
  rep(i, 26) cin >> c[i];
  rep2(i, 1, D+1)rep(j, 26) cin >> s[i][j];
}

void out() {
  rep2(i, 1, D+1) cout << best_ans[i]+1 << endl;
}

void construct() {
  //greedy
  rep(i, 26) best_last[i][0] = {0, 0};
  rep2(d, 1, D+1) {
    int mx_score = -INF;
    int nx_con = -1;
    rep(con, 26) {
      int tmp_score = best_score;
      calc_score(con, d, tmp_score);
      if (mx_score < tmp_score) {
        mx_score = tmp_score;
        nx_con = con;
      }
    }
    assert(nx_con != -1);
    best_score = mx_score;
    best_ans[d] = nx_con;
    rep(j, 26) {
      if (nx_con == j) {
        best_last[j][d] = {d, d};
        int k = d - 1;
        while (k >= 0) {
          if (best_last[nx_con][k].se != 366) break;
          best_last[nx_con][k].se = d;
          k--;
        }
      }
      else {
        best_last[j][d] = {best_last[j][d-1].fi, 366};
      }
    }
  }
  rep(i, 26) best_last[i][D+1] = {best_last[i][D].fi, 366};
  cerr << best_score << endl;
}

double w = 0.0;
double startTemp = 1500;
double endTemp = 100;
double temp = startTemp;
int SA_loop = 0;

void NN_2swap() {
  int d1 = 1 + Xor128() % D;
  int range = 15;
  //if (temp < 1000) range = 20;
  //if (temp < 500) range = 10;
  int diff = 1 + Xor128() % range;
  int co = 1 - 2 * (Xor128() % 2);
  int d2 = d1 + co * (1 + Xor128() % diff);
  if (d2 <= 0 || 365 < d2) return;
  if (d1 == d2) return;
  if (d1 > d2) swap(d1, d2);
  int nx_score = cur_score;
  int c1 = cur_ans[d1];
  int c2 = cur_ans[d2];
  if (c1 == c2) return;
  nx_score -= s[d1][c1];
  nx_score -= s[d2][c2];
  nx_score -= (int)c[c1] * ((int)cur_last[c1][d1+1].se - d1) * (d1 - (int)cur_last[c1][d1-1].fi);
  nx_score -= (int)c[c2] * ((int)cur_last[c2][d2+1].se - d2) * (d2 - (int)cur_last[c2][d2-1].fi);
  nx_score += s[d2][c1];
  nx_score += s[d1][c2];
  if (cur_last[c1][d2].fi == d1) {
    nx_score += (int)c[c1] * ((int)cur_last[c1][d2].se - d2) * (d2 - (int)cur_last[c1][d1-1].fi);
  }
  else {
    nx_score += (int)c[c1] * ((int)cur_last[c1][d2].se - d2) * (d2 - (int)cur_last[c1][d2].fi);
  }
  if (cur_last[c2][d1].se == d2) {
    nx_score += (int)c[c2] * ((int)cur_last[c2][d2+1].se - d1) * (d1 - (int)cur_last[c2][d1].fi);
  }
  else {
    nx_score += (int)c[c2] * ((int)cur_last[c2][d1].se - d1) * (d1 - (int)cur_last[c2][d1].fi);
  }

  double now_temp = temp;
  double prob = exp((nx_score - cur_score) / now_temp);
  bool FORCE = prob > (double)(Xor128() % INF) / INF;
  if (FORCE) {
    swap(cur_ans[d1], cur_ans[d2]);
    int l1 = cur_last[c1][d1-1].fi;
    int r1 = cur_last[c1][d1+1].se;
    if (r1 == cur_last[c1][d2].se) {
      cur_last[c1][d2] = {d2, d2};
      rep2(i, l1+1, r1) {
        if (i == d2) continue;
        if (i < d2) cur_last[c1][i] = {l1, d2};
        if (i > d2) cur_last[c1][i] = {d2, r1};
      }
    }
    else {
      rep2(i, l1+1, r1) {
        cur_last[c1][i] = {l1, r1};
      }
      cur_last[c1][d2] = {d2, d2};
      l1 = cur_last[c1][d2-1].fi;
      r1 = cur_last[c1][d2+1].se;
      rep2(i, l1+1, r1) {
        if (i == d2) continue;
        if (i < d2) cur_last[c1][i].se = d2;
        if (i > d2) cur_last[c1][i].fi = d2;
      }
    }
    int l2 = cur_last[c2][d2-1].fi;
    int r2 = cur_last[c2][d2+1].se;
    if (l2 == cur_last[c2][d1].fi) {
      cur_last[c2][d1] = {d1, d1};
      rep2(i, l2+1, r2) {
        if (i == d1) continue;
        if (i < d1) cur_last[c2][i] = {l2, d1};
        if (i > d1) cur_last[c2][i] = {d1, r2};
      }
    }
    else {
      rep2(i, l2+1, r2) {
        cur_last[c2][i] = {l2, r2};
      }
      cur_last[c2][d1] = {d1, d1};
      l2 = cur_last[c2][d1-1].fi;
      r2 = cur_last[c2][d1+1].se;
      rep2(i, l2+1, r2) {
        if (i == d1) continue;
        if (i < d1) cur_last[c2][i].se = d1;
        if (i > d1) cur_last[c2][i].fi = d1;
      }
    }
    cur_score = nx_score;
    if (best_score < cur_score) {
      best_score = cur_score;
      memcpy(best_ans, cur_ans, sizeof(cur_ans));
    }
  }
}

constexpr short swap_list[2][10][4] = {
  { {1, 2, 0}, {2, 0, 1} },
  { {1, 0, 3, 2}, {1, 2, 3, 0}, {1, 3, 0, 2}, {2, 0, 3, 1}, {2, 3, 0, 1}, {2, 3, 1, 0}, {3, 0, 1, 2}, {3, 2, 0, 1}, {3, 2, 1, 0} }
};

void NN_k_swap(int K) {
  short d[K], con[K]; //{day, contest}
  bool add[26] = {};
  int range = 13;
  //if (temp < 1000) range = 15;
  //if (temp < 500) range = 10;
  int center_d = 1 + Xor128() % D;
  int id = 0;
  while (id < K) {
    int diff = 1 + Xor128() % range;
    int co = 1 - 2 * (Xor128() % 2);
    int d1 = center_d + co * (1 + Xor128() % diff);
    if (d1 <= 0 || 365 < d1) continue;
    int c1 = cur_ans[d1];
    if (add[c1]) continue;
    add[c1] = true;
    con[id] = c1;
    d[id++] = d1;
  }
  //sort(all(dc));

  int nx_score = -INF;
  int erase_score = cur_score;
  short nx_d[K];
  rep(i, K) {
    erase_score -= s[d[i]][con[i]];
    erase_score -= (int)c[con[i]] * ((int)cur_last[con[i]][d[i]+1].se - d[i]) * (d[i] - (int)cur_last[con[i]][d[i]-1].fi);
  }
  int pattern = 2;
  if (K == 4) pattern = 9;
  rep(i, pattern) {
    int tmp_score = erase_score;
    short tmp_d[K];
    rep(j, K) {
      short idx = swap_list[K-3][i][j];
      short nd = d[idx];
      tmp_score += s[nd][con[j]];
      if (cur_last[con[j]][nd].fi == d[j]) {
        tmp_score += (int)c[con[j]] * ((int)cur_last[con[j]][nd].se - nd) * (nd - (int)cur_last[con[j]][d[j]-1].fi);
      }
      else if (cur_last[con[j]][nd].se == d[j]) {
        tmp_score += (int)c[con[j]] * ((int)cur_last[con[j]][d[j]+1].se - nd) * (nd - (int)cur_last[con[j]][nd].fi);
      }
      else {
        tmp_score += (int)c[con[j]] * ((int)cur_last[con[j]][nd].se - nd) * (nd - (int)cur_last[con[j]][nd].fi);
      }
      tmp_d[j] = nd;
    }
    if (nx_score < tmp_score) {
      nx_score = tmp_score;
      memcpy(nx_d, tmp_d, sizeof(tmp_d));
    }
  }
  double prob = exp((nx_score - cur_score) / temp);
  bool FORCE = prob > (double)(Xor128() % INF) / INF;
  if (FORCE) {
    rep(i, K) {
      cur_ans[nx_d[i]] = con[i];
      int l = cur_last[con[i]][d[i]-1].fi;
      int r = cur_last[con[i]][d[i]+1].se;
      if (l == cur_last[con[i]][nx_d[i]].fi) {
        cur_last[con[i]][nx_d[i]] = {nx_d[i], nx_d[i]};
        l = cur_last[con[i]][nx_d[i]-1].fi;
        r = cur_last[con[i]][d[i]+1].se;
        rep2(j, l+1, r) {
          if (j == nx_d[i]) continue;
          if (j < nx_d[i]) cur_last[con[i]][j] = {l, nx_d[i]};
          if (j > nx_d[i]) cur_last[con[i]][j] = {nx_d[i], r};
        }
      }
      else if (r == cur_last[con[i]][nx_d[i]].se) {
        cur_last[con[i]][nx_d[i]] = {nx_d[i], nx_d[i]};
        l = cur_last[con[i]][d[i]-1].fi;
        r = cur_last[con[i]][nx_d[i]+1].se;
        rep2(j, l+1, r) {
          if (j == nx_d[i]) continue;
          if (j < nx_d[i]) cur_last[con[i]][j] = {l, nx_d[i]};
          if (j > nx_d[i]) cur_last[con[i]][j] = {nx_d[i], r};
        }
      }
      else {
        rep2(j, l+1, r) {
          cur_last[con[i]][j] = {l, r};
        }
        cur_last[con[i]][nx_d[i]] = {nx_d[i], nx_d[i]};
        l = cur_last[con[i]][nx_d[i]-1].fi;
        r = cur_last[con[i]][nx_d[i]+1].se;
        rep2(j, l+1, r) {
          if (j == nx_d[i]) continue;
          if (j < nx_d[i]) cur_last[con[i]][j].se = nx_d[i];
          if (j > nx_d[i]) cur_last[con[i]][j].fi = nx_d[i];
        }
      }
    }
    cur_score = nx_score;
    if (best_score < cur_score) {
      best_score = cur_score;
      memcpy(best_ans, cur_ans, sizeof(cur_ans));
    }
  }
}


void NN_replace() {
  int d = 1 + Xor128() % D;
  int c1 = cur_ans[d];
  int c2 = Xor128() % 26;
  if (c1 == c2) return;
  int nx_score = cur_score;
  nx_score -= s[d][c1];
  nx_score += s[d][c2];
  nx_score -= c[c1] * ((int)cur_last[c1][d+1].se - d) * (d - (int)cur_last[c1][d-1].fi);
  nx_score += c[c2] * ((int)cur_last[c2][d].se - d) * (d - (int)cur_last[c2][d].fi);
  double now_temp = temp;
  double prob = exp((nx_score - cur_score) / now_temp);
  bool FORCE = prob > (double)(Xor128() % INF) / INF;
  if (FORCE) {
    cur_ans[d] = c2;
    int l1 = cur_last[c1][d-1].fi;
    int r1 = cur_last[c1][d+1].se;
    rep2(i, l1+1, r1) {
      cur_last[c1][i] = {l1, r1};
    }
    cur_last[c2][d] = {d, d};
    int l2 = cur_last[c2][d-1].fi;
    int r2 = cur_last[c2][d+1].se;
    rep2(i, l2+1, r2) {
      if (i == d) continue;
      if (i < d) cur_last[c2][i].se = d;
      if (i > d) cur_last[c2][i].fi = d;
    }
    cur_score = nx_score;
    if (best_score < cur_score) {
      best_score = cur_score;
      memcpy(best_ans, cur_ans, sizeof(cur_ans));
    }
  }
}

void improve() {
  startTemp = 1200;
  endTemp = 300;
  double st_time = get_time();
  timelimit = 1980;
  double SA_limit_time = timelimit - st_time; //SAにかける時間msec
  temp = startTemp;
  cur_score = best_score;
  memcpy(cur_last, best_last, sizeof(best_last));
  memcpy(cur_ans, best_ans, sizeof(best_ans));
  //double cool = 0.999999995;

  cerr << "before: " << best_score << endl;
  while (true) {
    SA_loop++;
    if (SA_loop % 50000 == 0) {
      double t = get_time() - st_time;
      temp = startTemp + (endTemp - startTemp) * t / SA_limit_time;
    }
    //temp *= cool;
    if (temp <= endTemp) break;
    //近傍
    int id = 0 + Xor128() % 6;
    if (id <= 2) NN_replace();
    else if (id == 3) NN_2swap();
    else if (id == 4) NN_k_swap(3);
    else if (id == 5) NN_k_swap(4);
    /*
    if (loop % 1000000 == 0) {
      cerr << loop << " " << cur_score << " " << best_score << " " << temp << endl;
    }
    */
  }
  //rep(i, 7) cerr << i << ":" << improve_cnt[i] << " ";
  //cerr << endl;
  cerr << SA_loop << " "  << temp << endl;
  cerr << "after: " << best_score << endl;
}

void solve() {
  construct();
  improve();
}

signed main() {
  seed(37);
  read();
  solve();
  out();
}


Measured memory_bytes: 4448