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();

    // 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
    const T0: f64 = 2e3;
    const T1: f64 = 6e2;
    const TL: f64 = 1.95;

    let mut rand = rand_pcg::Pcg64Mcg::new(890482);
    let mut state = State::new(&input, t);

    let mut cnt = 0;
    let mut T = T0;
    let mut best = state.score;
    let mut best_out = state.t.clone();

    loop {
        cnt += 1;
        if cnt % 100 == 0 {
            let t = get_time(time) / TL;
            if t >= 1.0 {
                break;
            }
            T = T0.powf(1.0 - t) * T1.powf(t);
        }

        let old_score = state.score;
        if rand.gen_bool(0.5) {
            let day = rand.gen_range(1, d + 1);
            let contest = rand.gen_range(1, 26 + 1);

            let old = state.t[day];
            state.change(&input, day, contest);
            let next_score = state.score;
            if old_score > next_score
                && !rand.gen_bool(f64::exp((state.score - old_score) as f64 / T))
            {
                state.change(&input, day, old);
            }
        } 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 old_score > next_score
                && !rand.gen_bool(f64::exp((state.score - old_score) as f64 / T))
            {
                state.change(&input, day1, contest1);
                state.change(&input, day2, contest2);
            }
        }
        if state.score > best {
            best = state.score;
            best_out = state.t.clone();
        }
    }

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


Measured memory_bytes: 3496