#pragma region kyopro_template
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define each(x, v) for (auto &x : v)
#define all(v) (v).begin(), (v).end()
#define sz(v) ((int)(v).size())
#define mem(a, val) memset(a, val, sizeof(a))
#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)
#define inl(...)         \
  long long __VA_ARGS__; \
  in(__VA_ARGS__)
#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__)
#define inc(...)    \
  char __VA_ARGS__; \
  in(__VA_ARGS__)
#define in2(s, t)                           \
  for (int i = 0; i < (int)s.size(); i++) { \
    in(s[i], t[i]);                         \
  }
#define in3(s, t, u)                        \
  for (int i = 0; i < (int)s.size(); i++) { \
    in(s[i], t[i], u[i]);                   \
  }
#define in4(s, t, u, v)                     \
  for (int i = 0; i < (int)s.size(); i++) { \
    in(s[i], t[i], u[i], v[i]);             \
  }
#define rep(i, N) for (long long i = 0; i < (long long)(N); i++)
#define repr(i, N) for (long long i = (long long)(N)-1; i >= 0; i--)
#define rep1(i, N) for (long long i = 1; i <= (long long)(N); i++)
#define repr1(i, N) for (long long i = (N); (long long)(i) > 0; i--)
using namespace std;
void solve();
using ll = long long;
template <class ll = ll>
using V = vector<ll>;
using vi = vector<int>;
using vl = vector<long long>;
using vvi = vector<vector<int>>;
using vd = V<double>;
using vs = V<string>;
using vvl = vector<vector<long long>>;
using P = pair<long long, long long>;
using vp = vector<P>;
using pii = pair<int, int>;
using vpi = vector<pair<int, int>>;
constexpr int inf = 1001001001;
constexpr long long infLL = (1LL << 61) - 1;
template <typename ll, typename U>
inline bool amin(ll &x, U y) {
  return (y < x) ? (x = y, true) : false;
}
template <typename ll, typename U>
inline bool amax(ll &x, U y) {
  return (x < y) ? (x = y, true) : false;
}
template <typename ll, typename U>
ll ceil(ll a, U b) {
  return (a + b - 1) / b;
}
constexpr ll TEN(int n) {
  ll ret = 1, x = 10;
  while (n) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
}

template <typename ll, typename U>
ostream &operator<<(ostream &os, const pair<ll, U> &p) {
  os << p.first << " " << p.second;
  return os;
}
template <typename ll, typename U>
istream &operator>>(istream &is, pair<ll, U> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename ll>
ostream &operator<<(ostream &os, const vector<ll> &v) {
  int s = (int)v.size();
  for (int i = 0; i < s; i++) os << (i ? " " : "") << v[i];
  return os;
}
template <typename ll>
istream &operator>>(istream &is, vector<ll> &v) {
  for (auto &x : v) is >> x;
  return is;
}
void in() {}
template <typename ll, class... U>
void in(ll &t, U &... u) {
  cin >> t;
  in(u...);
}
void out() { cout << "\n"; }
template <typename ll, class... U>
void out(const ll &t, const U &... u) {
  cout << t;
  if (sizeof...(u)) cout << " ";
  out(u...);
}
template <typename ll>
void die(ll x) {
  out(x);
  exit(0);
}

#ifdef NyaanDebug
#include "NyaanDebug.h"
#define trc(...)                   \
  do {                             \
    cerr << #__VA_ARGS__ << " = "; \
    dbg_out(__VA_ARGS__);          \
  } while (0)
#define trca(v, N)       \
  do {                   \
    cerr << #v << " = "; \
    array_out(v, N);     \
  } while (0)
#define trcc(v)                             \
  do {                                      \
    cerr << #v << " = {";                   \
    each(x, v) { cerr << " " << x << ","; } \
    cerr << "}" << endl;                    \
  } while (0)
#else
#define trc(...)
#define trca(...)
#define trcc(...)
int main() { solve(); }
#endif

struct IoSetupNya {
  IoSetupNya() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cerr << fixed << setprecision(7);
  }
} iosetupnya;

inline int popcnt(unsigned long long a) { return __builtin_popcountll(a); }
inline int lsb(unsigned long long a) { return __builtin_ctzll(a); }
inline int msb(unsigned long long a) { return 63 - __builtin_clzll(a); }
template <typename ll>
inline int getbit(ll a, int i) {
  return (a >> i) & 1;
}
template <typename ll>
inline void setbit(ll &a, int i) {
  a |= (1LL << i);
}
template <typename ll>
inline void delbit(ll &a, int i) {
  a &= ~(1LL << i);
}
template <typename ll>
int lb(const vector<ll> &v, const ll &a) {
  return lower_bound(begin(v), end(v), a) - begin(v);
}
template <typename ll>
int ub(const vector<ll> &v, const ll &a) {
  return upper_bound(begin(v), end(v), a) - begin(v);
}
template <typename ll>
vector<ll> mkrui(const vector<ll> &v) {
  vector<ll> ret(v.size() + 1);
  for (int i = 0; i < int(v.size()); i++) ret[i + 1] = ret[i] + v[i];
  return ret;
};
template <typename ll>
vector<ll> mkuni(const vector<ll> &v) {
  vector<ll> ret(v);
  sort(ret.begin(), ret.end());
  ret.erase(unique(ret.begin(), ret.end()), ret.end());
  return ret;
}
template <typename F>
vector<int> mkord(int N, F f) {
  vector<int> ord(N);
  iota(begin(ord), end(ord), 0);
  sort(begin(ord), end(ord), f);
  return ord;
}
template <typename ll = int>
vector<ll> mkiota(int N) {
  vector<ll> ret(N);
  iota(begin(ret), end(ret), 0);
  return ret;
}

#pragma endregion

constexpr int MOD = /** 998244353;  //*/ 1000000007;

namespace Simulated_Annealing {

// timer
struct Timer {
  chrono::high_resolution_clock::time_point st;

  Timer() { reset(); }

  void reset() { st = chrono::high_resolution_clock::now(); }

  chrono::milliseconds::rep elapsed() {
    auto ed = chrono::high_resolution_clock::now();
    return chrono::duration_cast<chrono::milliseconds>(ed - st).count();
  }
};

// random number generator
unsigned long long rng() {
  static unsigned long long x_ = 88172645463325252ULL;
  x_ = x_ ^ (x_ << 7);
  return x_ = x_ ^ (x_ >> 9);
}

// exp高速化用のlogテーブル
// exp(d/T) > rng()  <=>  d > T * log(rng)を使い前計算
struct gen_log {
  double l[65536];
  constexpr gen_log() : l() {
    unsigned long long x = 88172645463325252ULL;
    double log_u64max = log(2) * 64;
    for (int i = 0; i < 65536; i++) {
      x = x ^ (x << 7);
      x = x ^ (x >> 9);
      l[i] = log(double(x)) - log_u64max;
    }
  }
};
constexpr auto rnd_log = gen_log();

// 時間
constexpr double start_time = 0;
constexpr double end_time = 1980;
constexpr double inv_time = 1.0 / (end_time - start_time);
double cur_time = 0;

// 温度 開始温度は実行時に渡す
constexpr double end_temp = 1;
double cur_temp;

// スコア
using score_t = long long;
score_t score = 0, diff = 0;

// 入力用,答え用変数
constexpr int D = 365;
int C[26], S[D + 1][26];
bitset<384> up[26], down[26];
int ans[D + 1];

// 入力
void input() {
  ini(dummy);
  rep(i, 26) in(C[i]);
  rep1(i, D) rep(j, 26) in(S[i][j]);
}

// 出力
void output() { rep1(i, D) cout << ans[i] + 1 << "\n"; }

// 初期解を構築してスコアを計算
void init() {
  score = 0;
  rep(i, 26) {
    up[i].reset();
    down[i].reset();
    up[i][0] = up[i][366] = 1;
    down[i][0] = down[i][366] = 1;
  }
  vl v(26), last(26, 0);
  rep1(i, D) {
    rep(j, 26) { v[j] = S[i][j] + C[j] * (i - last[j]); }
    int mx = max_element(all(v)) - begin(v);
    up[mx][i] = down[mx][366 - i] = 1;
    last[mx] = i;
    ans[i] = mx;
    rep(j, 26) {
      if (j == mx)
        score += S[i][j];
      else
        score -= C[j] * (i - last[j]);
    }
  }
}

// 状態変数(古い状態と新しい状態をメモする用)
int mode = 0;  // 遷移のパターン用の変数
int d, old, nxt;

int d1, d2;

// 遷移先を設定
void set_state(int iter) {
  mode = iter % 2;
  if (mode == 0) {
    d = rng() % D + 1;
    old = ans[d];
    do {
      nxt = rng() % 26;
    } while (old == nxt);
  } else {
    int dist = rng() % 13 + 1;
    do {
      d1 = rng() % (D - dist) + 1;
    } while (ans[d1] == ans[d1 + dist]);
    d2 = d1 + dist;
    old = ans[d1], nxt = ans[d2];
  }
}

int on, nn;

ll calc(int d, int old, int nxt) {
  // assert(up[old][d] == 1 and down[nxt][d] == 0);
  int oldr = up[old]._Find_next(d);
  int oldl = 366 - down[old]._Find_next(366 - d);
  int nxtr = up[nxt]._Find_next(d);
  int nxtl = 366 - down[nxt]._Find_next(366 - d);
  return (d - oldl) * (d - oldr) * C[old] - S[d][old] -
         (d - nxtl) * (d - nxtr) * C[nxt] + S[d][nxt];
}

// 差分を計算
void calc_diff() {
  if (mode == 0) {
    diff = calc(d, old, nxt);
  } else {
    diff = calc(d1, old, nxt);
    up[old][d1] = down[old][366 - d1] = 0;
    up[nxt][d1] = down[nxt][366 - d1] = 1;
    diff += calc(d2, nxt, old);
    up[old][d1] = down[old][366 - d1] = 1;
    up[nxt][d1] = down[nxt][366 - d1] = 0;
  }
}

// 遷移を採用して更新
void update() {
  if (mode == 0) {
    up[old][d] = down[old][366 - d] = 0;
    up[nxt][d] = down[nxt][366 - d] = 1;
    ans[d] = nxt;
  } else {
    up[old][d1] = down[old][366 - d1] = 0;
    up[nxt][d1] = down[nxt][366 - d1] = 1;
    up[nxt][d2] = down[nxt][366 - d2] = 0;
    up[old][d2] = down[old][366 - d2] = 1;
    swap(ans[d1], ans[d2]);
  }
}

// 実行
void simulated_annealing(double startTemp, Timer *timer = nullptr,
                         bool is_tuning = false) {
  // タイマーの設定
  if (timer == nullptr) timer = new Timer();
  //チューニング時はタイマーをリセット
  if (is_tuning) timer->reset();

  // 焼きなまし関連のconstでない変数の初期化
  cur_time = 0;
  cur_temp = startTemp;
  score = diff = 0;

  // 初期解の構築
  init();

  // イテレーションの回数
  int iter = 0;
  while (true) {
    // 256回に1回、時間と温度を更新する
    if ((++iter & 0xFF) == 0) {
      if ((cur_time = timer->elapsed()) > end_time) break;
      cur_temp =
          end_temp + (startTemp - end_temp) * (end_time - cur_time) * inv_time;
    }

    // 次の遷移を設定
    set_state(iter);

    // 差分を計算
    calc_diff();

    // 条件を満たしたときに遷移を採用
    if (double(diff) > cur_temp * rnd_log.l[iter & 0xFFFF]) {
      // スコアと状態を更新
      score += diff;
      update();
    }
// デバッグ用に 65536 iteration毎に出力
#ifdef NyaanDebug
    if (!is_tuning and (iter & 0x3FFFFF) == 0) {
      cerr << cur_time << "\t" << iter << "\t" << score << endl;
    }
#endif
  }

// 結果を出力
#ifdef NyaanDebug
  cerr << iter << "\t" << score << endl;
#endif
}

// 実行用
void run(double temp) {
  Timer timer;
  input();
  simulated_annealing(temp, &timer);
  output();
  return;
}

void test(const vector<string> &filenames, double temp) {
  double result = 0.0;
  Timer timer;
  for (auto &filename : filenames) {
    cerr << filename << "\t" << temp << "\t";
    ifstream is(filename);
    cin.rdbuf(is.rdbuf());
    input();
    simulated_annealing(temp, &timer, true);
    result += score;
  }
  cerr << "result : " << result << endl;
}

// パラメータ調整
// スコアの管理はオーバーフローに備えてdoubleを使っている
void tuningTemp(const vector<string> &filenames, double left_log2 = 0,
                double right_log2 = 16, double range = 0.0,
                map<double, double> *mp = nullptr) {
  constexpr int range_size = 8;

  cerr << "range : " << exp2(left_log2) << " ~ " << exp2(right_log2) << endl;

  // 値の範囲がある程度絞られたらreturn
  if (right_log2 - left_log2 <= range) {
    assert(mp != nullptr);
    cerr << "tuning finished." << endl;
    cerr << "left_log_2 : " << left_log2 << endl;
    cerr << "right_log_2 : " << right_log2 << endl;
    for (int i = 0; i <= range_size; i += 2) {
      double cur_log = left_log2 + (right_log2 - left_log2) * i / range_size;
      cerr << "temp : " << exp2(cur_log) << " \t, val = " << (*mp)[cur_log]
           << endl;
    }
    return;
  }

  // mapの初期化
  if (mp == nullptr) mp = new map<double, double>;
  // timerの初期化
  Timer timer;

  // 雑に対数軸で等分して調べる
  vector<double> score1(range_size + 1, 0);
  for (int i = 0; i <= range_size; i++) {
    double cur_log = left_log2 + (right_log2 - left_log2) * i / range_size;
    if ((*mp).find(cur_log) != (*mp).end()) {
      score1[i] = (*mp)[cur_log];
    } else {
      double t = exp2(cur_log);
      for (auto &filename : filenames) {
        cerr << filename << "\t" << t << "\t";
        ifstream is(filename);
        cin.rdbuf(is.rdbuf());
        input();
        simulated_annealing(t, &timer, true);
        score1[i] += score;
      }
      (*mp)[cur_log] = score1[i];
    }
  }

  // 結果を貼る
  cerr << "experiment finished." << endl;
  for (int i = 0; i <= range_size; i++) {
    double cur_log = left_log2 + (right_log2 - left_log2) * i / range_size;
    cerr << "log : " << cur_log;
    cerr << "\t temp : " << exp2(cur_log);
    cerr << "\t score : " << score1[i] << endl;
  }

  // 再帰的に調べたい場合は下のコメント化を外す
  /**
  // 範囲のスコアを雑に重みづけして計算
  int half_range = range_size / 2;
  vector<double> score2(half_range + 1, 0);
  for (int i = 0; i <= half_range; i++) {
    for (int j = 0; j <= half_range; j++) {
      double weight = pow(2, min(j, half_range - j));
      score2[i] += weight * score1[i + j];
    }
  }

  // 最大である区間を次の探索先として決定
  int mx = max_element(begin(score2), end(score2)) - begin(score2);
  double left2 = left_log2 + (right_log2 - left_log2) * mx / range_size;
  double right2 =
      left_log2 + (right_log2 - left_log2) * (mx + half_range) / range_size;

  // tuningTemp(filenames, left2, right2, range, mp);
  //*/

  return;
}

}  // namespace Simulated_Annealing
namespace SA = Simulated_Annealing;

void solve() {
  vs files = {"input0", "input1", "input2", "input3", "input4", "input5",
                  "input6", "input7", "input8", "input9"};
  
  //SA::tuningTemp({ files,10.5,11.5);
  //SA::test(files, exp2(10.75));
  SA::run(exp2(10.75));
}

Measured memory_bytes: 4232