#include <array>
#include <vector>
#include <algorithm>
#include <array>
#include <chrono>
#include <iostream>
#include <random>
#include <vector>


template <int d, int t>
class LinkedList
{
public:
    struct Node
    {
        int type;
        int index;
        int prev;
        int next;
    };

    LinkedList(std::vector<int>& state)
    {
        for (int i = 0; i <= d + 1; i++)
        {
            contents[i].index = i;
        }
        std::array<int, t + 1> type_list;
        for (int i = 0; i <= t; i++)
        {
            type_list[i] = 0;
        }
        for (int i = 1; i <= d; i++)
        {
            const auto type = state[i - 1];
            contents[i].type = type;
            contents[i].prev = type_list[type];
            contents[contents[i].prev].next = i;
            type_list[type] = i;
        }
        for (int i = 1; i <= t; i++)
        {
            contents[type_list[i]].next = d + 1;
        }
    }

    LinkedList(const LinkedList& src) { copy_from(src); }

    int& value(const int index) { return contents[index].type; }

    const int& value(const int index) const { return contents[index].type; }

    /**
     * @param index 1-index で示される位置
     * @param type 直前の位置
     */
    int next_same_type(const int index, const int type) const
    {
        if (contents[index].type == type)
        {
            return contents[index].next;
        }
        else
        {
            int next_index = index + 1;
            while (next_index <= d && contents[next_index].type != type)
            {
                next_index++;
            }
            return next_index;
        }
    }

    int prev_same_type(const int index, const int type) const
    {
        if (contents[index].type == type)
        {
            return contents[index].prev;
        }
        else
        {
            int prev_index = index - 1;
            while (0 < prev_index && contents[prev_index].type != type)
            {
                prev_index--;
            }
            return prev_index;
        }
    }

    void change(const int index, const int type_to, const int prev_index, const int next_index)
    {
        const int type_from = contents[index].type;
        if (type_from == type_to)
        {
            return;
        }
        auto& cur = contents[index];

        auto& p = contents[cur.prev];
        auto& n = contents[cur.next];
        p.next = n.index;
        n.prev = p.index;

        cur.type = type_to;

        contents[prev_index].next = cur.index;
        cur.prev = contents[prev_index].index;

        contents[next_index].prev = cur.index;
        cur.next = contents[next_index].index;
    }

    void change(const int index, const int type_to)
    {
        const int type_from = contents[index].type;
        const int prev_index = prev_same_type(index, type_to);
        const int next_index = next_same_type(index, type_to);

        change(index, type_to, prev_index, next_index);
    }

    void copy_from(const LinkedList& src) { std::copy(src.contents.begin(), src.contents.end(), contents.begin()); }

private:
    std::array<Node, d + 2> contents;
};

using namespace std;

constexpr int d = 365;
constexpr int t = 26;
constexpr double rest_time = 1950;

struct Problem
{
    vector<int64_t> cs;
    vector<vector<int64_t>> ss;

    void load()
    {
        cs.resize(t + 1);

        for (int i = 1; i <= t; i++)
        {
            cin >> cs[i];
        }

        ss.resize(d + 1, vector<int64_t>(t + 1));
        for (int i = 1; i <= d; i++)
        {
            for (int j = 1; j <= t; j++)
            {
                cin >> ss[i][j];
            }
        }
    }
};

struct State
{
    using value_t = int64_t;

    struct Diff
    {
        using value_t = State::value_t;

        vector<int> accum_cs;
        uniform_int_distribution<int> day_rand;
        uniform_int_distribution<int> weighted_type_rand;

        void initialize(const Problem& p)
        {
            accum_cs.resize(t + 1, 0);
            for (int i = 0; i < t; i++)
            {
                accum_cs[i + 1] = p.cs[i];
                accum_cs[i + 1] += accum_cs[i];
            }
            {
                decltype(day_rand)::param_type param(1, d);
                day_rand.param(param);
            }
            {
                decltype(weighted_type_rand)::param_type param(1, accum_cs.back());
                weighted_type_rand.param(param);
            }
        }

        /**
         * ランダムに振った結果、採択するなら受け入れる
         */
        bool randomize(const Problem& p, const State& s, mt19937_64& mt)
        {
            date = day_rand(mt);
            const int r = weighted_type_rand(mt);
            type_from = s.state.value(date);
            type_to = 0;
            for (int i = 0; i < t; i++)
            {
                if (accum_cs[i] <= r && r < accum_cs[i + 1])
                {
                    type_to = i;
                }
            }
            type_to++;
            return type_from != type_to;
        }

        int date;

        int type_from;
        int type_to;

        // for evaluation
        int to_prev_index;
        int to_next_index;

        value_t eval_diff;
    };

    LinkedList<d, t> state;

    value_t eval;

    State(std::vector<int>& s) : state(s) {}

    State(State& src) : state(src.state) {}

    void dump(ostream& out)
    {
        for (int i = 1; i <= d; i++)
        {
            out << state.value(i) << endl;
        }
    }

    void apply(const Diff& diff)
    {
        state.change(diff.date, diff.type_to, diff.to_prev_index, diff.to_next_index);
        eval += diff.eval_diff;
    }

    void revert(const Diff& diff) {}

    void test(const Diff& diff) {}

    void copy_from(const State& src)
    {
        state.copy_from(src.state);

        eval = src.eval;
    }
};

class Evaluator
{
public:
    using value_t = State::value_t;

    value_t evaluate(const Problem& p, const State& s) const
    {
        value_t sum = 0;

        for (int j = 0; j < t; j++)
        {
            sum += evaluate_line(p, s, j);
        }
        return sum;
    }

    value_t evaluate_diff(const Problem& p, const State& s, State::Diff& diff) const
    {
        const int from_prev_index = s.state.prev_same_type(diff.date, diff.type_from);
        const int from_next_index = s.state.next_same_type(diff.date, diff.type_from);

        diff.to_prev_index = s.state.prev_same_type(diff.date, diff.type_to);
        diff.to_next_index = s.state.next_same_type(diff.date, diff.type_to);

        return (diff.to_next_index - diff.date) * (diff.date - diff.to_prev_index) * p.cs[diff.type_to] -
               (from_next_index - diff.date) * (diff.date - from_prev_index) * p.cs[diff.type_from];
    }

    value_t evaluate_line(const Problem& p, const State& s, const int j) const
    {
        int last = -1;
        int64_t sum = 0;
        for (int i = 1; i <= d; i++)
        {
            sum += p.ss[i][s.state.value(i)];
            if (s.state.value(i) == j)
            {
                last = i;
            }
            sum -= p.cs[j] * (i - last);
        }
        return sum;
    }
};

/**
 * 最大化問題を解くための焼き鈍し法
 */
class SimulatedAnnealing
{
public:
    void solve(const Problem& p, const Evaluator& evaluator, State& s, mt19937_64& mt);
};

void SimulatedAnnealing::solve(const Problem& p, const Evaluator& evaluator, State& s, mt19937_64& mt)
{
    const auto start = chrono::system_clock::now();

    State best_state(s);

    double rate = 1.0;

    State::Diff diff;
    diff.initialize(p);

    uniform_real_distribution<double> prob_rand;

    int counter = 0;
    while (true)
    {
        if (!diff.randomize(p, s, mt))
        {
            continue;
        }

        s.test(diff);
        diff.eval_diff = evaluator.evaluate_diff(p, s, diff);

        if (diff.eval_diff > 0 || exp(diff.eval_diff * rate * 0.15) > prob_rand(mt))
        {
            s.apply(diff);
        }
        else
        {
            s.revert(diff);
        }

        if (counter++ % 1000 == 0)
        {
            const auto end = chrono::system_clock::now();
            const auto duration = chrono::duration_cast<chrono::milliseconds>(end - start).count();
            if (duration > rest_time)
            {
                std::cerr << "counter = " << counter << std::endl;
                std::cerr << "iter [t/s] = " << (counter * 1000.0 / duration) << std::endl;

                break;
            }
            rate = (rest_time - duration) / rest_time;
        }
        if (best_state.eval < s.eval)
        {
            best_state.copy_from(s);
        }
    }
    s.copy_from(best_state);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    {
        int _;
        cin >> _;
    }

    Problem p;
    p.load();

    mt19937_64 mt(0);
    uniform_int_distribution<int> rand(1, t);

    Evaluator e;

    vector<int> s;
    {
        s.resize(d);
        for (int i = 0; i < d; i++)
        {
            s[i] = rand(mt);
        }
    }
    State state(s);
    state.eval = e.evaluate(p, state);

    SimulatedAnnealing sa;
    sa.solve(p, e, state, mt);

    state.dump(cout);
}


Measured memory_bytes: 3896