#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define INF 1e9

static const int seed=701;
static const int D=365;
static const int ntype=26;
static const int population_size=50;
int gene[population_size][D+1];
int next_gene[population_size][D+1];
static int elete[D+1];
static long long elete_score=-INF;
static const int init_n_greedyGene=1;
static const double crossRate=0.8;
static const double mutationRate=0.5;
vector<pair<double, int>> cumfreq;

//Info
int change_time=0;
int crossover_time=0;
int mutation_time=0;

void Info(){
    cout<<"change: "<<change_time<<endl;
    cout<<"crossover: "<<crossover_time<<endl;
    cout<<"mutation: "<<mutation_time<<endl;
}

class Contest{
public:
    Contest(){
        last=0;
    }
    int s[D+1];
    int c;
    int last;
};

Contest contest[ntype+1];

void Input(){
    int d;
    cin>>d;
    for(int i=1;i<=ntype;++i){
        int t;
        cin>>t;
        contest[i].c=t;
    }
    for(int day=1;day<=D;++day){
        for(int type=1;type<=ntype;++type){
            int t;
            cin>>t;
            contest[type].s[day]=t;
        }
    }
}

void randGene(int p){
    for(int day=1;day<=D;++day){
        gene[p][day]=rand()%ntype+1;
    }
}

void greedyGene(int p){
    vector<int> l(ntype+1,0);
    long long score=0;
    for(int d=1;d<=D;++d){
        for(int i=1;i<=ntype;++i) score-=contest[i].c*(d-l[i]);
        long long temp=score;
        int t=-1;
        for(int i=1;i<=ntype;++i){
            long long k=contest[i].s[d]+contest[i].c*(d-l[i])+score;
            if(k>temp){
                temp=k;
                t=i;
            }
        }
        gene[p][d]=t;
        l[t]=d;
    }
}

int evaluate(int i){
    int v[D+1];
    v[0]=0;
    vector<int> l(ntype+1,0);
    for(int day=1;day<=D;++day){
        v[day]=v[day-1];
        int type=gene[i][day];
        v[day]+=contest[type].s[day];
        l[type]=day;
        for(int t=1;t<=ntype;++t){
            v[day]-=contest[t].c*(day-l[t]);
        }
        //cout<<day<<" :"<<v[day]<<endl;
    }
    return v[D];   
}

void calcCumFreq(){
    int n=cumfreq.size();
    sort(cumfreq.begin(),cumfreq.end());
    //change elete
    if(elete_score<(int)cumfreq[n-1].first){
        ++change_time;
        elete_score=(int)cumfreq[n-1].first;
        int i=cumfreq[n-1].second;
        for(int d=1;d<=D;++d) elete[d]=gene[i][d];
    }
    double sum=n*(n+1)/2.0;
    for(int i=0;i<n;++i){
        cumfreq[i].first=(i+1)/sum;
    }
    for(int i=0;i<n-1;++i){
        cumfreq[i+1].first+=cumfreq[i].first;
    }
}

void CrossOver(int gene_i, int ci, int cj){
    ++crossover_time;
    for(int d=1;d<=D;++d) next_gene[gene_i][d]=gene[ci][d];
    int p=rand()%D+1;
    next_gene[gene_i][p]=gene[cj][p];
    /*int l=rand()%D+1;
    int r=rand()%D+1;
    while(r==l){
        l=rand()%D+1;
        r=rand()%D+1;
    }
    if(r<l) swap(r,l);
    for(int d=1;d<l;++d) next_gene[gene_i][d]=gene[ci][d];
    for(int d=l;d<=r;++d) next_gene[gene_i][d]=gene[cj][d];
    for(int d=r+1;d<=D;++d) next_gene[gene_i][d]=gene[ci][d];
    */
}

void Mutation(int ngene_i){
    ++mutation_time;
    int n=1;
    for(int i=0;i<n;++i){
        int p=rand()%D+1;
        next_gene[ngene_i][p]=rand()%ntype+1;
    }
}

int Select(){
    double a=(double)rand()/RAND_MAX;
    int t=cumfreq.size()-1;
    for(int i=0;i<t;++i){
        if(cumfreq[i+1].first>a) return cumfreq[i].second;
    }
    return cumfreq[t].second;
}

//init
void Init(int nGreedy){
    for(int i=0;i<nGreedy;++i){
        greedyGene(i);
    }
    for(int i=nGreedy;i<population_size;++i){
        randGene(i);
    }
}

void makeCumFreq(){
    for(int i=0;i<population_size;++i){
        double e=(double)evaluate(i);
        cumfreq.push_back(make_pair(e,i));
    }
    calcCumFreq();
}

void makeNextGeneration(){
    for(int d=1;d<=D;++d) next_gene[0][d]=elete[d]; 
    for(int i=1;i<population_size;++i){
        int pi=Select();
        double crossrand=(double)rand()/RAND_MAX;
        if(crossrand<crossRate){
            int pj=Select();
            CrossOver(i,pi,pj);
        }
        else{
            for(int j=1;j<=D;++j) next_gene[i][j]=gene[pi][j];
        }
        double murand=(double)rand()/RAND_MAX;
        if(murand<mutationRate){
            Mutation(i);
        }
    }
    for(int i=0;i<50;++i){
        for(int j=1;j<=D;++j){
            gene[i][j]=next_gene[i][j];
        }
    }
}

void GA(int n){
    for(int i=0;i<n;++i){
        makeCumFreq();
        makeNextGeneration();
        cumfreq.resize(0);
    }    
}

void Output(){
    for(int d=1;d<=D;++d) cout<<elete[d]<<endl;
}

int main(){
    srand(seed);
    Input();
    Init(1);
    GA(4000);
    Output();
}

Measured memory_bytes: 3680