use proconio::input;
use rand::Rng;

pub fn get_time() -> f64 {
    static mut STIME: f64 = -1.0;
    let t = std::time::SystemTime::now()
        .duration_since(std::time::UNIX_EPOCH)
        .unwrap();
    let ms = t.as_secs() as f64 + t.subsec_nanos() as f64 * 1e-9;
    unsafe {
        if STIME < 0.0 {
            STIME = ms;
        }
        ms - STIME
    }
}

pub struct State {
    max_day: usize,
    sat: isize,
    out: Vec<usize>,
    last: Vec<usize>,
    c: Vec<isize>,
    s: Vec<Vec<isize>>,
}

impl State {
    fn calclate_score(&mut self) -> isize {
        self.sat = 0;
        self.last = vec![0; 26];
        let mut s: isize = 0;
        for i in 0..26 {
            s += self.c[i];
        }
        let mut temp_minus = 0;
        for d in 0..self.max_day {
            temp_minus += s;
            assert!(0 <= self.out[d] && self.out[d] <= 25);
            let j = self.out[d as usize] as usize;
            temp_minus -= self.c[j] * (d + 1 - self.last[j]) as isize;
            self.sat -= temp_minus;
            self.last[j] = d + 1;
            self.sat += self.s[d][j];
        }
        self.sat
    }
    fn initialize_output(&mut self) {
        for i in 0..self.max_day {
            let mut max = 0;
            for j in 0..26 {
                max = if self.s[i][max] < self.s[i][j] {
                    j
                } else {
                    max
                };
            }
            self.out[i] = max;
        }
        for i in 0..self.max_day {
            let mut max = self.out[i];
            let mut max_score = self.calclate_score();
            for j in 0..26 {
                self.out[i] = j;
                let temp = self.calclate_score();
                if max_score < temp {
                    max = j;
                    max_score = temp;
                }
            }
            self.out[i] = max;
        }
        eprintln!("initial score: {}", self.calclate_score());
    }
}

fn solve_sa(plan: &mut State) {
    const T0: f64 = 2e3;
    const T1: f64 = 6e2;
    const TL: f64 = 1.9;
    let mut rng = rand::thread_rng();
    let mut T = T0;
    let mut max_score = plan.calclate_score();
    let mut loop_cnt = 0;
    loop {
        // eprintln!("{}", max_score);
        loop_cnt += 1;
        let t = get_time() / TL;
        if t >= 1.0 {
            break;
        }
        T = T0.powf(1.0 - t) * T1.powf(t);
        if rng.gen_bool(0.5) {
            let d1 = rng.gen_range(0, plan.max_day - 1);
            let d2 = rng.gen_range(d1 + 1, (d1 + 13).min(plan.max_day));
            let old1 = plan.out[d1];
            let old2 = plan.out[d2];
            plan.out[d1] = old2;
            plan.out[d2] = old1;
            let score = plan.calclate_score();
            if max_score > score && !rng.gen_bool(f64::exp((score - max_score) as f64 / T)) {
                plan.out[d1] = old1;
                plan.out[d2] = old2;
            } else {
                max_score = score;
            }
        } else {
            let d: usize = rng.gen_range(0, plan.max_day);
            let q: usize = rng.gen_range(0, 26);
            let old = plan.out[d];
            plan.out[d] = q;
            let score = plan.calclate_score();
            if max_score > score && !rng.gen_bool(f64::exp((score - max_score) as f64 / T)) {
                plan.out[d] = old;
            } else {
                max_score = score;
            }
        }
    }
    eprintln!("score:{}, loop:{}", max_score, loop_cnt);
}

fn main() {
    input! {
        max_day: usize,
        c: [isize; 26],
        s: [[isize; 26]; max_day],
    }
    let mut plan = State {
        max_day: max_day,
        sat: 0,
        out: vec![0; max_day],
        last: vec![0; 26],
        c,
        s,
    };
    plan.initialize_output();
    solve_sa(&mut plan);
    for x in plan.out {
        println!("{}", x + 1);
    }
}


Measured memory_bytes: 3400