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 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();
    let mut rng = rand::thread_rng();
    let mut max_score = plan.calclate_score();
    let mut loop_cnt = 0;
    while get_time() < 1.9 {
        // eprintln!("{}", max_score);
        if rng.gen_bool(0.5) {
            let d1 = rng.gen_range(0, 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 {
                max_score = score;
            } else {
                plan.out[d1] = old1;
                plan.out[d2] = old2;
            }
        } else {
            let d: usize = rng.gen_range(0, 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 {
                max_score = score;
            } else {
                plan.out[d] = old;
            }
        }
        loop_cnt += 1;
    }
    for x in plan.out {
        println!("{}", x + 1);
    }
    eprintln!("score:{}, loop:{}", max_score, loop_cnt);
}


Measured memory_bytes: 2784