use proconio::{fastout, input};

use rand::prelude::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::time::SystemTime;

struct Input {
    d: usize,
    c: Vec<i64>,
    s: Vec<[i64; 26 + 1]>,
}

struct State {
    t: Vec<usize>,
    score: i64,
    event_days: Vec<Vec<usize>>,
}

// 0日目,最終日
fn cost(a: usize, b: usize) -> i64 {
    // println!("{} {}", a, b);
    let d = b - a;
    (d * (1 + d) / 2) as i64
}

impl State {
    fn new(input: &Input, t: Vec<usize>) -> State {
        let mut event_days = vec![vec![]; 26 + 1];
        for day in 1..=input.d {
            event_days[t[day]].push(day);
        }
        let score = calc_score(&input, &t);
        State {
            t,
            score,
            event_days,
        }
    }
    // day: 変更日, new_contest: コンテスト番号
    fn change(&mut self, input: &Input, day: usize, new_contest: usize) {
        let old_contest = self.t[day];
        // println!("event {:?}", self.event_days[old_contest]);

        let p = self.event_days[old_contest]
            .iter()
            .position(|a| *a == day)
            .unwrap();
        let prev_day = if p == 0 {
            0
        } else {
            self.event_days[old_contest].get(p - 1).cloned().unwrap()
        };
        let next_day = self.event_days[old_contest]
            .get(p + 1)
            .cloned()
            .unwrap_or(input.d + 1);
        self.event_days[old_contest].remove(p);
        self.score += (cost(prev_day, day - 1) + cost(day, next_day - 1)
            - cost(prev_day, next_day - 1))
            * input.c[old_contest];

        let p = self.event_days[new_contest]
            .iter()
            .position(|a| *a > day)
            .unwrap_or(self.event_days[new_contest].len());
        let prev_day = if p == 0 {
            0
        } else {
            self.event_days[new_contest].get(p - 1).cloned().unwrap()
        };
        let next_day = self.event_days[new_contest]
            .get(p)
            .cloned()
            .unwrap_or(input.d + 1);
        self.event_days[new_contest].insert(p, day);
        self.score -= (cost(prev_day, day - 1) + cost(day, next_day - 1)
            - cost(prev_day, next_day - 1))
            * input.c[new_contest];
        self.score += input.s[day][new_contest] - input.s[day][old_contest];
        self.t[day] = new_contest;
    }
}

fn calc_score(input: &Input, t: &Vec<usize>) -> i64 {
    let mut res = 0;
    let mut last: [usize; 26 + 1] = [0; 26 + 1];
    for day in 1..=input.d {
        let now_contest = t[day];
        res += input.s[day][now_contest];
        last[now_contest] = day;
        for contest in 1..=26 {
            res -= input.c[contest] * (day - last[contest]) as i64;
        }
    }
    res
}

fn get_time(time: SystemTime) -> f64 {
    time.elapsed().unwrap().as_secs_f64()
}

#[fastout]
fn main() {
    let time = SystemTime::now();
    let mut rand = rand_pcg::Pcg64Mcg::new(890482);

    // input
    input! {
        d: usize,
        _c: [i64; 26],
        _s: [[i64; 26]; d],
    }

    let mut c = vec![0];
    c.extend(_c.iter());

    let mut s = vec![[0; 26 + 1]; d + 1];
    for day in 1..=d {
        for contest in 1..=26 {
            s[day][contest] = _s[day - 1][contest - 1]
        }
    }

    let input = Input { d, c, s };

    let t = vec![1; d + 1];

    // process
    let mut state = State::new(&input, t);
    let mut score = state.score;
    while get_time(time) < 1.95 {
        for _ in 1..=1000 {
            if rand.gen_bool(0.5) {
                let day = rand.gen_range(1, d + 1);
                let contest = rand.gen_range(1, 26 + 1);

                let tmp = state.t[day];
                state.change(&input, day, contest);
                let next_score = state.score;
                if next_score > score {
                    score = next_score;
                } else {
                    state.change(&input, day, tmp);
                }
            } else {
                let day1 = rand.gen_range(1, d);
                let day2 = rand.gen_range(day1 + 1, min(d + 1, day1 + 16));

                let contest1 = state.t[day1];
                let contest2 = state.t[day2];
                state.change(&input, day1, contest2);
                state.change(&input, day2, contest1);

                let next_score = state.score;
                if next_score > score {
                    score = next_score;
                // println!("{} {}", score, get_time(time));
                } else {
                    state.change(&input, day1, contest1);
                    state.change(&input, day2, contest2);
                }
            }
        }
    }

    for i in 1..=d {
        println!("{}", state.t[i]);
    }
}


Measured memory_bytes: 2404