#include <queue>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iostream>
#include <fstream>
#include <chrono>
#include <random>

using namespace std;

auto start_time = chrono::system_clock::now();

inline bool timeout(int ms) {
    auto delta = chrono::system_clock::now() - start_time;
    return chrono::duration_cast<chrono::milliseconds>(delta).count() >= ms;
}

inline int spent() {
    auto delta = chrono::system_clock::now() - start_time;
    return chrono::duration_cast<chrono::milliseconds>(delta).count();
}

inline int pct(int ms) {
    auto delta = chrono::system_clock::now() - start_time;
    return 100.0 * chrono::duration_cast<chrono::milliseconds>(delta).count() / ms;
}

class Pts {
public:
    Pts(int n, int d) : mem(n) {
        for (auto &a : mem) {
            a.reserve(d + 1);
            a.push_back(-1);
            a.push_back(d);
        }
    }

    inline pair<int, int> get(int t, int k) {
        auto &a = mem[k];
        auto i = lower_bound(a.begin(), a.end(), t);
        if (*i == t) return {*(i - 1), *(i + 1)};
        else return {*(i - 1), *i};
    }

    inline void set(int t, int i) {
        auto &b = mem[i];
        auto j = lower_bound(b.begin(), b.end(), t);
        b.insert(j, t);
    }

    inline void unset(int t, int i) {
        auto &a = mem[i];
        auto j = find(a.begin(), a.end(), t);
        a.erase(j);
    }

private:
    vector<vector<int>> mem;
};

const int n = 26;

class Solution {
public:
    Solution(int n, int d) :
            n(n), d(d), cost(0),
            c(n), s(d, vector<int>(n)),
            res(d), pts(n, d) {

        for (auto &x : c) cin >> x;

        for (int t = 0; t < d; t++) {
            for (int i = 0; i < n; i++) {
                cin >> s[t][i];
            }
        }

        for (int t = 0; t < d; t++) {
            int i = max_element(s[t].begin(), s[t].end()) - s[t].begin();
            res[t] = i;
            cost += s[t][i];
            int q = pts.get(t, i).first;
            cost -= c[i] * (t - q - 1) * (t - q) / 2;
            pts.set(t, i);
        }

        for (int i = 0; i < n; i++) {
            int q = pts.get(d, i).first;
            cost -= c[i] * (d - q - 1) * (d - q) / 2;
        }
    }

    inline int64_t estimate(int t, int j) {
        int i = res[t];
        int64_t delta = s[t][j] - s[t][i];
        {
            auto p = pts.get(t, i);
            int l = t - p.first - 1;
            int r = p.second - t - 1;
            delta += c[i] * (l * (l + 1) + r * (r + 1) - (l + r + 1) * (l + r + 2)) / 2;
        }
        {
            auto p = pts.get(t, j);
            int l = t - p.first - 1;
            int r = p.second - t - 1;
            delta -= c[j] * (l * (l + 1) + r * (r + 1) - (l + r + 1) * (l + r + 2)) / 2;
        }
        return delta;
    }

    inline void change(int t, int j, int64_t delta) {
        int i = res[t];
        res[t] = j;
        pts.unset(t, i);
        pts.set(t, j);
        cost += delta;
    }

    inline vector<int> &result() {
        return res;
    }

    inline int64_t get_cost() {
        return cost;
    }

private:
    int n;
    int d;
    int64_t cost;
    vector<int> c;
    vector<vector<int>> s;
    vector<int> res;
    Pts pts;
};

void solver(int a, double b) {
    start_time = chrono::system_clock::now();

    int d;
    cin >> d;

    Solution solution(n, d);

    minstd_rand rnd(start_time.time_since_epoch().count());
    int cnt = 0;
    const int tmt = 1950;
    int p = a;

    vector<int> bestr(d);
    int64_t bestc = INT64_MIN;
    int64_t max_delta = 0;
    int64_t avg_delta = 0;
    int resets = 0;

    while (cnt % (1 << 5) || !timeout(tmt)) {
        max_delta = 0;
        if (cnt % (1 << 5) == 0) {
            double left = max(0.1, 100.0 - pct(tmt));
            p = a * left / 100;

            if (cnt % (1 << 10) == 0) {
                cerr << "epoch: " << cnt << "(" << left << "%): " << solution.get_cost()
                     << " - p=" << p / 100.0 << "% " << avg_delta << " : " << resets << "\n";
                resets = 0;
            }

            if (bestc - solution.get_cost() > b * avg_delta) {
                for (int t = 0; t < d; t++) {
                    int i = bestr[t];
                    auto delta = solution.estimate(t, i);
                    solution.change(t, i, delta);
                }
                resets += 1;
            }
            if (solution.get_cost() > bestc) {
                bestc = solution.get_cost();
                bestr = solution.result();
            }
        }

        for (int t = 0; t < d; t++) {
            unsigned r = rnd() % 10007;
            unsigned i = r % n;
            int64_t delta = solution.estimate(t, i);
            if (delta > 0 || r < p) {
                solution.change(t, i, delta);
                max_delta = max(max_delta, delta);
            }
        }
        if (max_delta > 0) avg_delta = 0.9 * avg_delta + 0.1 * max_delta;

        cnt++;
    }

    if (solution.get_cost() < bestc) {
        for (int t = 0; t < d; t++) {
            int i = bestr[t];
            auto delta = solution.estimate(t, i);
            solution.change(t, i, delta);
        }
    }

//    cerr << "final (" << a / 100.0 << "% : " << b << ") " << spent() << " ms: " << solution.get_cost() << '\n';

    for (auto &x : solution.result()) cout << x + 1 << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);

    solver(10, 5);

    return 0;
}


Measured memory_bytes: 3900