//#define NDEBUG
#include "bits/stdc++.h"
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <random>
#ifdef _MSC_VER
#include <ppl.h>
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <boost/rational.hpp>
//#include <opencv2/core.hpp>
//#include <opencv2/imgproc.hpp>
//#include <opencv2/highgui.hpp>
//#else
//#include <omp.h>
#endif


using namespace std;

#define DUMPOUT cerr
#define dump(...) DUMPOUT<<"  ";DUMPOUT<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl;DUMPOUT<<"    ";dump_func(__VA_ARGS__)

using uint = unsigned; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; using pll = pair<ll, ll>; using pdd = pair<double, double>; using pss = pair<string, string>;
template <typename _KTy, typename _Ty> ostream& operator << (ostream& o, const pair<_KTy, _Ty>& m) { o << "{" << m.first << ", " << m.second << "}"; return o; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& o, const map<_KTy, _Ty>& m) { if (m.empty()) { o << "{ }"; return o; } o << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { o << ", " << *itr; } o << "}"; return o; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& o, const unordered_map<_KTy, _Ty>& m) { if (m.empty()) { o << "{ }"; return o; } o << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { o << ", " << *itr; } o << "}"; return o; }
template <typename _Ty> ostream& operator << (ostream& o, const vector<_Ty>& v) { if (v.empty()) { o << "{ }"; return o; } o << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { o << ", " << *itr; } o << "}"; return o; }
template <typename _Ty> ostream& operator << (ostream& o, const deque<_Ty>& v) { if (v.empty()) { o << "{ }"; return o; } o << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { o << ", " << *itr; } o << "}"; return o; }
template <typename _Ty> ostream& operator << (ostream& o, const set<_Ty>& s) { if (s.empty()) { o << "{ }"; return o; } o << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { o << ", " << *itr; } o << "}"; return o; }
template <typename _Ty> ostream& operator << (ostream& o, const unordered_set<_Ty>& s) { if (s.empty()) { o << "{ }"; return o; } o << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { o << ", " << *itr; }	o << "}"; return o; }
template <typename _Ty> ostream& operator << (ostream& o, const stack<_Ty>& s) { if (s.empty()) { o << "{ }"; return o; } stack<_Ty> t(s); o << "{" << t.top(); t.pop(); while (!t.empty()) { o << ", " << t.top(); t.pop(); } o << "}";	return o; }
template <typename _Ty> ostream& operator << (ostream& o, const list<_Ty>& l) { if (l.empty()) { o << "{ }"; return o; } o << "{" << l.front(); for (auto itr = ++l.begin(); itr != l.end(); ++itr) { o << ", " << *itr; } o << "}"; return o; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& is, pair<_KTy, _Ty>& m) { is >> m.first >> m.second; return is; }
template <typename _Ty> istream& operator >> (istream& is, vector<_Ty>& v) { for (size_t t = 0; t < v.size(); t++) is >> v[t]; return is; }
template <typename _Ty> istream& operator >> (istream& is, deque<_Ty>& v) { for (size_t t = 0; t < v.size(); t++) is >> v[t]; return is; }
namespace aux { // print tuple
  template<typename Ty, unsigned N, unsigned L> struct tp { static void print(ostream& os, const Ty& v) { os << get<N>(v) << ", "; tp<Ty, N + 1, L>::print(os, v); } };
  template<typename Ty, unsigned N> struct tp<Ty, N, N> { static void print(ostream& os, const Ty& v) { os << get<N>(v); } };
}

template<typename... Tys> ostream& operator<<(ostream& os, const tuple<Tys...>& t) { os << "{"; aux::tp<tuple<Tys...>, 0, sizeof...(Tys) - 1>::print(os, t); os << "}"; return os; }

template<typename A, size_t N, typename T> inline void Fill(A(&array)[N], const T& val) { fill((T*)array, (T*)(array + N), val); }

template <typename ... Args>
std::string format(const std::string& fmt, Args ... args) {
  size_t len = std::snprintf(nullptr, 0, fmt.c_str(), args ...);
  std::vector<char> buf(len + 1);
  std::snprintf(&buf[0], len + 1, fmt.c_str(), args ...);
  return std::string(&buf[0], &buf[0] + len);
}

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(move(tail)...); }

#define PI 3.14159265358979323846
#define EPS 1e-8
#define rep(t,n) for(int t=0;t<(n);++t)
#define ALL(j) (j).begin(), (j).end()
#define SZ(j) ((int)(j).size())
#define fake false

class Timer {
public:
  double t = 0;
  Timer() {}
  static double time() {
#ifdef _MSC_VER
    return __rdtsc() / 2.8e9;
#else
    unsigned long long a, d;
    __asm__ volatile("rdtsc"
      : "=a"(a), "=d"(d));
    return (d << 32 | a) / 3.0e9;
#endif
  }
  void measure() { t = time() - t; }
  double elapsedMs() { return (time() - t) * 1000.0; }
} timer;

struct Xorshift {
  uint64_t x = 88172645463325252LL;
  unsigned next_int() {
    x = x ^ (x << 7);
    return x = x ^ (x >> 9);
  }
  unsigned next_int(unsigned mod) {
    x = x ^ (x << 7);
    x = x ^ (x >> 9);
    return x % mod;
  }
  unsigned next_int(unsigned l, unsigned r) {
    x = x ^ (x << 7);
    x = x ^ (x >> 9);
    return x % (r - l + 1) + l;
  }
  double next_double() {
    return double(next_int()) / UINT_MAX;
  }
} rnd;

template<typename T>
void shuffle_vector(vector<T>& v, Xorshift& rnd) {
  int n = v.size();
  for (int i = n - 1; i >= 1; i--) {
    int r = rnd.next_int(i);
    swap(v[i], v[r]);
  }
}



double lrnd[1 << 16];

void initialize() {
  rep(i, 1000) rnd.next_int();
  rep(i, 1 << 16) lrnd[i] = log(rnd.next_double());
}

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

struct State {
  int day;
  int score;
  int last[N];
  int t[D];
  State() {}
  void init() {
    day = 0;
    score = 0;
    rep(i, N) last[i] = -1;
  }
  int calc_diff(int i) {
    int diff = 0, p;
    diff += s[day][i];
    p = last[i];
    last[i] = day;
    for (int k = 0; k < N; k++)
      diff -= c[k] * (day - last[k]);
    last[i] = p;
    return diff;
  }
  void choose_greedy() {
    int best_diff = INT_MIN, best_i = -1;
    for (int i = 0; i < N; i++) {
      int diff = calc_diff(i);
      if (best_diff < diff) {
        best_diff = diff;
        best_i = i;
      }
    }
    score += best_diff;
    last[best_i] = day;
    t[day] = best_i;
    day++;
  }
  void output(ostream& o) {
    rep(d, D) o << t[d] + 1 << '\n';
  }
};

struct State2 {
  int t[D];
  int ctods[N][D];
  int sz[N];
  int score;
  State2() {}
  void init(const State& state) {
    score = 0;
    rep(i, N) {
      ctods[i][0] = -1;
      ctods[i][1] = D;
      sz[i] = 2;
    }
    rep(d, D) {
      t[d] = state.t[d];
      insert(state.t[d], d);
    }
    int cnt = 0;
    rep(i, N) {
      int prev = -1;
      for (int idx = 1; idx < sz[i]; idx++) {
        int d = ctods[i][idx];
        cnt++;
        score += s[d][i];
        int l = d - prev - 1;
        score -= c[i] * l * (l + 1) / 2;
        prev = d;
      }
    }
    dump(cnt, score);
  }
  inline int lower_bound(int i, int d) const {
    for (int j = 1; j < sz[i]; j++) if (d <= ctods[i][j]) return j;
  }
  inline void insert(int i, int d) {
    int idx = lower_bound(i, d);
    for (int j = sz[i]; j > idx; j--) ctods[i][j] = ctods[i][j - 1];
    ctods[i][idx] = d;
    sz[i]++;
  }
  inline void erase(int i, int d) {
    int idx = lower_bound(i, d);
    for (int j = idx; j < sz[i] - 1; j++) ctods[i][j] = ctods[i][j + 1];
    sz[i]--;
  }
  // i: contest, d: day, idx: index
  int change_diff(int d, int i) const {
    int pi = t[d], idx1 = lower_bound(pi, d), idx2 = lower_bound(i, d);
    return
      s[d][i] - s[d][pi]
      + c[pi] * (d - ctods[pi][idx1 - 1]) * (d - ctods[pi][idx1 + 1])
      - c[i] * (d - ctods[i][idx2 - 1]) * (d - ctods[i][idx2]);
  }
  void change(int d, int i, int diff) {
    int pi = t[d];
    erase(pi, d);
    insert(i, d);
    t[d] = i;
    score += diff;
  }
  int slide_diff(int d1, int d2) const {
    int i = t[d1], idx = lower_bound(i, d1), pd1 = ctods[i][idx - 1], nd1 = ctods[i][idx + 1];
    if (pd1 < d2 && d2 < nd1) {
      return s[d2][i] - s[d1][i]
        + c[i] * (d1 - pd1) * (d1 - nd1)
        - c[i] * (d2 - pd1) * (d2 - nd1);
    }
    else {
      int nidx = lower_bound(i, d2), pd2 = ctods[i][nidx - 1], nd2 = ctods[i][nidx];
      return s[d2][i] - s[d1][i]
        + c[i] * (d1 - pd1) * (d1 - nd1)
        - c[i] * (d2 - pd2) * (d2 - nd2);
    }
  }
  int swap_diff(int d1, int d2) const {
    return slide_diff(d1, d2) + slide_diff(d2, d1);
  }
  void swap(int d1, int d2, int diff) {
    int i1 = t[d1], i2 = t[d2];
    erase(i1, d1); erase(i2, d2);
    insert(i2, d1); insert(i1, d2);
    std::swap(t[d1], t[d2]);
    score += diff;
  }
  void output(ostream& o) {
    rep(d, D) o << t[d] + 1 << '\n';
  }
};

struct State3 {
  int t[D];
  int pday[N][D];
  int nday[N][D];
  int score;
  State3() {}
  void init(const State& state) {
    score = 0;
    rep(i, N) rep(d, D) {
      pday[i][d] = -1;
      nday[i][d] = D;
    }
    rep(d, D) {
      t[d] = state.t[d];
      insert(state.t[d], d);
    }
    for (int d = 0; d < D; d++) {
      int i = t[d], pd = pday[i][d], nd = nday[i][d];
      score += s[d][i];
      score -= c[i] * (d - pd) * (d - pd - 1) / 2;
    }
    for (int i = 0; i < N; i++) {
      if (t[D - 1] == i) continue;
      int pd = pday[i][D - 1];
      score -= c[i] * (D - pd) * (D - pd - 1) / 2;
    }
    dump(score);
  }
  inline void insert(int i, int d) {
    // d 日目にコンテスト i を挿入する
    int pd = max(0, pday[i][d]), nd = min(D - 1, nday[i][d]);
    for (int cd = d - 1; cd >= pd; cd--) nday[i][cd] = d;
    for (int cd = d + 1; cd <= nd; cd++) pday[i][cd] = d;
  }
  inline void erase(int i, int d) {
    int pd = pday[i][d], nd = nday[i][d];
    for (int cd = max(0, pd); cd < nd; cd++) nday[i][cd] = nd;
    for (int cd = min(D - 1, nd); cd > pd; cd--) pday[i][cd] = pd;
  }
  // i: contest, d: day, idx: index
  int change_diff(int d, int i) const {
    int pi = t[d];
    return
      s[d][i] - s[d][pi]
      + c[pi] * (d - pday[pi][d]) * (d - nday[pi][d])
      - c[i] * (d - pday[i][d]) * (d - nday[i][d]);
  }
  void change(int d, int i, int diff) {
    int pi = t[d];
    erase(pi, d);
    insert(i, d);
    t[d] = i;
    score += diff;
  }
  int slide_diff(int d1, int d2) const {
    int i = t[d1], pd1 = pday[i][d1], nd1 = nday[i][d1];
    if (pd1 < d2 && d2 < nd1) {
      return s[d2][i] - s[d1][i] + c[i] * ((d1 - pd1) * (d1 - nd1) - (d2 - pd1) * (d2 - nd1));
    }
    else {
      int pd2 = pday[i][d2], nd2 = nday[i][d2];
      return s[d2][i] - s[d1][i] + c[i] * ((d1 - pd1) * (d1 - nd1) - (d2 - pd2) * (d2 - nd2));
    }
  }
  int swap_diff(int d1, int d2) const {
    return slide_diff(d1, d2) + slide_diff(d2, d1);
  }
  void swap(int d1, int d2, int diff) {
    int i1 = t[d1], i2 = t[d2];
    erase(i1, d1); erase(i2, d2);
    insert(i2, d1); insert(i1, d2);
    std::swap(t[d1], t[d2]);
    score += diff;
  }
  void output(ostream& o) {
    rep(d, D) o << t[d] + 1 << '\n';
  }
};

double invT;
double getTemp(double startTemp, double endTemp, double t, double T) {
  return endTemp + (startTemp - endTemp) * (T - t) * invT;
}

int main() {
  timer.measure();
  initialize();

  ios::sync_with_stdio(false);
  cin.tie(0);

#ifdef _MSC_VER
  ifstream ifs("C:\\Users\\komori3\\Desktop\\6f4c9d0cfda6a311fea2d9cf23e4f032\\tester\\in1.txt");
  istream& in = ifs;
  ofstream ofs("C:\\Users\\komori3\\Desktop\\6f4c9d0cfda6a311fea2d9cf23e4f032\\tester\\out1.txt");
  ostream& out = ofs;
#else
  istream& in = cin;
  ostream& out = cout;
#endif

  string buf;
  in >> buf;
  rep(i, N) in >> c[i];
  rep(d, D) rep(i, N) in >> s[d][i];

  vector<int> v(D);
  for (int i = 0; i < D; i++) v[i] = i % 26;

  State best_state;
  int best_score = INT_MIN;

  best_state.init();
  rep(d, D) best_state.choose_greedy();
  best_score = best_state.score;

  dump(best_score);

  State3 state3;
  state3.init(best_state);

  double start_temp = 3000;
  double end_temp = 1;
  double start_time = timer.elapsedMs();
  double end_time = 1970;
  double duration = end_time - start_time;
  double inv_duration = 1.0 / duration;
  auto get_temp = [&](double t) {
    return end_temp + (start_temp - end_temp) * (end_time - t) * inv_duration;
  };

  int loop = 0;
  double time = timer.elapsedMs();
  constexpr int width = 15;
  while (true) {
    if (loop & 1) {
      int d = rnd.next_int(D), i;
      do {
        i = rnd.next_int(N);
      } while (i == state3.t[d]);

      int diff = state3.change_diff(d, i);

      double temp = get_temp(time);
      if (diff > temp * lrnd[loop & 0xFFFF]) {
        state3.change(d, i, diff);
      }
    }
    else {
      int d1 = rnd.next_int(D - width), d2;
      do {
        d2 = d1 + rnd.next_int(width + 1);
      } while (state3.t[d1] == state3.t[d2]);

      int diff = state3.swap_diff(d1, d2);

      double temp = get_temp(time);
      if (diff > temp * lrnd[loop & 0xFFFF]) {
        state3.swap(d1, d2, diff);
      }
    }

    loop++;
    if (!(loop & 0xFFFFFF)) {
      dump(loop, state3.score);
    }
    if (!(loop & 0xFF)) {
      time = timer.elapsedMs();
      if (end_time < time) break;
    }
  }
  dump(loop, state3.score);

  state3.output(out);

  return 0;
}


Measured memory_bytes: 4600