#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 998244353
#define INIT -1

int d;
int c[26];
int s[365][26];
vector<set<int>> schedule(26);
vector<int> nowSchedule;

int getScore()
{
   int res = 0;
   for (int i = 0; i < 26; i++)
   {
      for (auto itr = schedule[i].begin(); itr != schedule[i].end(); itr++)
      {
         if (itr != schedule[i].begin())
         {
            res += s[*itr][i];
            auto previtr = itr;
            previtr--;
            res -= c[i] * (*itr - *previtr - 1) * (*itr - *previtr) / 2;
         }
      }
   }
   return res;
}

int getDiffScore(int tmpd, int tmpq)
{
   // res: tmpdにtmpqを開催するようになったときの満足度の増加量
   int res = 0;
   // nextd: 問題tmpqのtmpd以降で最初の開催日
   auto nextitr = schedule[tmpq].lower_bound(tmpd);
   int nextd = *nextitr;
   // prevd: 問題tmpqのtmpd以前で最後の開催日
   auto previtr = nextitr;
   previtr--;
   int prevd = *previtr;
   // tmpd ~ nextd - 1までのtmpqに関する今の満足度低下量の合計は
   // c[tmpq] * (tmpd - prevd) + ... + c[tmpq] * (nextd - 1 - prevd)
   // tmpdにtmpqを開催した時のtmpd ~ nextd - 1までのtmpqに関する満足度低下量の合計は
   // c[tmpq] * 0 + ... + c[tmpq] * (nextd - 1 - tmpd)
   res += c[tmpq] * ((nextd - 1 - prevd) * (nextd - prevd) / 2 - (tmpd - prevd - 1) * (tmpd - prevd) / 2) - c[tmpq] * (nextd - 1 - tmpd) * (nextd - tmpd) / 2;
   res += s[tmpd][tmpq];

   int prevq = nowSchedule[tmpd];
   // nextd: 問題prevqのtmpd以降で最初の開催日
   nextitr = schedule[prevq].upper_bound(tmpd);
   nextd = *nextitr;
   // prevd: 問題prevのtmpd以前で最後の開催日
   previtr = nextitr;
   previtr--;
   previtr--;
   prevd = *previtr;
   // tmpd ~ nextd - 1までのprevqに関する今の満足度低下量の合計は
   // c[prevq] * 0 + ... + c[prevq] * (nextd - 1 - tmpd)
   // tmpdにprevqを開催しなかった時のtmpd ~ nextd - 1までのtmpqに関する満足度低下量の合計は
   // c[prevq] * (tmpd - prevd) + ... + c[prevq] * (nextd - 1 - prevd)
   res += c[prevq] * (nextd - 1 - tmpd) * (nextd - tmpd) / 2 - c[prevq] * ((nextd - 1 - prevd) * (nextd - prevd) / 2 - (tmpd - prevd - 1) * (tmpd - prevd) / 2);
   res -= s[tmpd][prevq];
   return res;
}

int main()
{
   cin >> d;
   for (int i = 0; i < 26; i++)
   {
      cin >> c[i];
   }
   for (int i = 0; i < d; i++)
   {
      for (int j = 0; j < 26; j++)
      {
         cin >> s[i][j];
      }
   }
   nowSchedule = vector<int>(d);
   for (int i = 0; i < 26; i++)
   {
      schedule[i].insert(-1);
      schedule[i].insert(d);
   }
   for (int i = 0; i < d; i++)
   {
      nowSchedule[i] = i % 26;
      schedule[nowSchedule[i]].insert(i);
   }
   // int m;
   // cin >> m;
   int score = getScore();
   int prevd = 0;
   std::srand(std::time(nullptr)); // use current time as seed for random generator
   for (int i = 0; i < 100000; i++)
   {
      int tmpd = prevd + (-1) * (std::rand() % 2 + 1) * std::rand() % 5;
      if (tmpd < 0)
         tmpd = 0;
      if (tmpd >= d)
         tmpd = d - 1;
      int maxDiffScore = 0;
      int selectedq = -1;
      for (int j = 0; j < 26; j++)
      {
         int tmpDiffScore = getDiffScore(tmpd, j);
         if (tmpDiffScore > maxDiffScore)
         {
            maxDiffScore = tmpDiffScore;
            selectedq = j;
         }
      }
      if (selectedq >= 0)
      {
         schedule[nowSchedule[tmpd]].erase(tmpd);
         nowSchedule[tmpd] = selectedq;
         schedule[selectedq].insert(tmpd);
      }
   }
   for (int i = 0; i < d; i++)
   {
      cout << nowSchedule[i] + 1 << endl;
   }
}

Measured memory_bytes: 3660