#include <bits/stdc++.h>
using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T>
ostream& operator<<(ostream& o, const set<T>& st){
    vector<T> v(st.begin(),st.end());
    o<<"{ "<<join(v)<<" }";
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int D = 365;
int N = 26;
vi c;
vvi s;
random_device rnd;

struct State {
    ll score;
    vi t;
    vector<multiset<int>> last;
    State(vi &t): t(all(t)){
        last = vector<multiset<int>>(N);
        rep(i,N) last[i].insert(-1);
        rep(i,D) last[t[i]].insert(i);
        rep(i,N) last[i].insert(D);
        score = init_score();
    }
    ll init_score(){
        ll res = 0;
        vi _last(N, -1);
        rep(i,D){
            res += s[i][t[i]];
            _last[t[i]] = i;
            rep(j,N){
                res -= c[j] * (i - _last[j]);
            }
        }
        return res;
    }
    ll diff_with_erased(int day, int con){
        int pday = *--last[con].lower_bound(day);
        int nday = *++last[con].lower_bound(day);
        int diff = -s[day][con];
        diff -= c[con] * (day - pday) * (nday - day);
        return diff;
    }
    ll diff_with_assigned(int day, int con){
        int pday = *--last[con].lower_bound(day);
        int nday = *last[con].lower_bound(day);
        int diff = s[day][con];
        diff += c[con] * (day - pday) * (nday - day);
        return diff;
    }
    void erase_contest(int day, int con){
        score += diff_with_erased(day, con);
        t[day] = -1;
        last[con].erase(day);
    }
    void assign_contest(int day, int con){
        score += diff_with_assigned(day, con);
        t[day] = con;
        last[con].insert(day);
    }
};

vi greedy(){
    vi t(D);
    vi last(N, -1);
    rep(i,D){
        int idx = 0;
        int score = 0;
        rep(j,N){
            int jscore = s[i][j] + (c[j] * (i - last[j]));
            if(score < jscore){
                score = jscore;
                idx = j;
            }
        }
        t[i] = idx;
        last[idx] = i;
    }
    return t;
}

// return: if it was updated.
bool one_change(State &stat){
    int day = rnd() % D;
    int cur = rnd() % N;
    int pre = stat.t[day];
    if(cur == pre) return false;
    int diff = stat.diff_with_erased(day, pre)
             + stat.diff_with_assigned(day, cur);
    if(diff > 0){
        stat.erase_contest(day, pre);
        stat.assign_contest(day, cur);
        return true;
    }
    return false;
}

// return: if it was updated.
bool two_swap(State &stat){
    int W = 16;
    int day1 = rnd() % D;
    int day2 = day1 + (rnd() % (2*W)) - W;
    day2 = max(day2, 0);
    day2 = min(day2, D-1);
    if(day1 == day2) return false;
    int con1 = stat.t[day1];
    int con2 = stat.t[day2];

    int diff = stat.diff_with_erased(day1, con1)
             + stat.diff_with_erased(day2, con2)
             + stat.diff_with_assigned(day1, con2)
             + stat.diff_with_assigned(day2, con1);
    if(diff > 0){
        stat.erase_contest(day1, con1);
        stat.erase_contest(day2, con2);
        stat.assign_contest(day1, con2);
        stat.assign_contest(day2, con1);
        return true;
    }
    return false;
}

void search(State &stat){
    auto start = chrono::system_clock::now();
    ll loopcnt = 0;
    while(1){
        if(loopcnt % 100 == 0){
            auto now = chrono::system_clock::now();
            double elapsed = chrono::duration_cast<chrono::milliseconds>(now-start).count();
            if(elapsed > 1900) break;
        }

        bool updated = false;
        if(rnd() % 100 > 50){
            updated = one_change(stat);
        }else{
            updated = two_swap(stat);
        }
        // if(updated) debug(loopcnt)
        loopcnt++;
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    finput("./tester/data/test1.in");
    cin >> D;
    c = vi(N);
    s = vvi(D, vi(N));
    rep(i,N) cin >> c[i];
    rep(i,D) rep(j,N) cin >> s[i][j];

    vi t = greedy();
    State stat(t);
    search(stat);
    // debug(stat.score)
    for(auto ti : stat.t){
        cout << ti+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 4008