use proconio::input;
use rand::Rng;
use std::cmp::{max, min};
use std::i64;
use std::ops::{Bound, RangeBounds};
use std::time::{Duration, Instant};
struct Evaluator {
    dd: usize,
    penalty: Vec<i64>,
    holding: Vec<Vec<i64>>,
    select: Vec<usize>,
    last: Vec<[usize; 26]>,
    score: Vec<i64>,
}
impl Evaluator {
    fn new(dd: usize, penalty: Vec<i64>, holding: Vec<Vec<i64>>, select: Vec<usize>) -> Evaluator {
        Evaluator {
            dd,
            penalty,
            holding,
            select,
            last: vec![Default::default(); dd],
            score: vec![0; dd],
        }
    }
    fn calc_last_all(&mut self) {
        for d in 0..self.dd {
            if d > 0 {
                self.last[d] = self.last[d - 1];
            }
            self.last[d][self.select[d]] = d + 1;
        }
    }
    fn update_last_after(&mut self, day: usize, old_contest: usize, new_contest: usize) -> usize {
        let mut need_update_to = day;
        let old = if day == 0 {
            0
        } else {
            self.last[day - 1][old_contest]
        };
        assert_eq!(self.last[day][old_contest], day + 1);
        for d in day..self.dd {
            if self.last[d][old_contest] != day + 1 {
                need_update_to = max(need_update_to, d);
                break;
            }
            self.last[d][old_contest] = old;
        }
        let first_last = self.last[day][new_contest];
        for d in day..self.dd {
            if self.last[d][new_contest] != first_last {
                need_update_to = max(need_update_to, d);
                break;
            }
            self.last[d][new_contest] = day + 1;
        }
        need_update_to
    }
    fn calc_all(&mut self) -> i64 {
        self.calc_last_all();
        self.calc_range(..)
    }
    fn calc_range<R: RangeBounds<usize>>(&mut self, range: R) -> i64 {
        let start = match range.start_bound() {
            Bound::Included(&x) => x,
            Bound::Excluded(&x) => x + 1,
            Bound::Unbounded => 0,
        };
        let end = min(
            self.dd,
            match range.end_bound() {
                Bound::Included(&x) => x + 1,
                Bound::Excluded(&x) => x,
                Bound::Unbounded => self.dd,
            },
        );
        for d in start..end {
            self.score[d] = 0;
            self.score[d] += self.holding[d][self.select[d]];
            #[allow(clippy::needless_range_loop)]
            for i in 0..26 {
                self.score[d] -= self.penalty[i] * (d + 1 - self.last[d][i]) as i64;
            }
        }
        self.score.iter().sum()
    }
    fn change_contest(&mut self, day: usize, contest: usize) -> i64 {
        self.update_last_after(day, self.select[day], contest);
        self.select[day] = contest;
        self.calc_range(day..)
    }
}
fn main() {
    let timer = Instant::now();
    input! { dd : usize , c : [ i64 ; 26 ] , s : [ [ i64 ; 26 ] ; dd ] , }
    let mut select = Vec::new();
    let mut last = [0; 26];
    for d in 0..dd {
        let mut maxvalue = i64::MIN;
        let mut maxi = 0;
        for i in 0..26 {
            let mut value = 0;
            {
                let lastlast = last[i];
                last[i] = d + 1;
                value += s[d][i];
                #[allow(clippy::needless_range_loop)]
                for i in 0..26 {
                    value -= c[i] * (d + 1 - last[i]) as i64;
                }
                last[i] = lastlast;
            }
            if value > maxvalue {
                maxvalue = value;
                maxi = i;
            }
        }
        last[maxi] = d + 1;
        select.push(maxi);
    }
    let mut rng = rand::thread_rng();
    let mut eval = Evaluator::new(dd, c, s, select);
    let mut current_value = eval.calc_all();
    let mut update = 0;
    let before = current_value;
    while timer.elapsed() < Duration::from_millis(1980) {
        update += 1;
        let day = rng.gen_range(0, dd);
        let contest = rng.gen_range(0, 25);
        let old_contest = eval.select[day];
        let changed_value = eval.change_contest(day, contest);
        if current_value > changed_value {
            eval.change_contest(day, old_contest);
        } else {
            current_value = changed_value;
        }
    }
    eprintln!(
        "before: {}; after: {} ({} update)",
        before, current_value, update
    );
    for contest in eval.select {
        println!("{}", contest + 1);
    }
}



Measured memory_bytes: 2844