use std::time::{Instant, Duration};
use rand::{Rng, SeedableRng};
use rand::rngs::SmallRng;
use proconio::input;

#[proconio::fastout]
fn main() {
    let start = Instant::now();
    input! {
        d: i32,
        c: [i32; 26],
        s: [[i32; 26]; d],
    }
    let mut greedy_result = greedy(d, &c, &s);
    greedy_result.satification += local_search(d, &c, &s, &mut greedy_result.contests, start);
    let s: String = greedy_result.contests.iter()
                    .map(|x| (x+1).to_string())
                    .collect::<Vec<String>>()
                    .join("\n");
    println!("{}", s);
    eprintln!("score: {}", std::cmp::max(10i32.pow(6)+greedy_result.satification, 0));
}

struct BestResult {
    satification: i32,
    contests: Vec<usize>
}

fn greedy(d: i32, c: &Vec<i32>, s: &Vec<Vec<i32>>) -> BestResult {
    let mut satification = 0;
    let mut last: Vec<i32> = vec![0; 26];
    let mut contests: Vec<usize> = vec![0; d as usize];
    for i in 1..d+1 {
        let mut best_contest: usize = 1;
        let mut best_satification = -1_000_000_000;
        for t in 0..26 {
            let pre_last = last[t];
            last[t] = i;
            last[t as usize] = i as i32;
            let tmp_satification = {
                satification
                + s[(i-1) as usize][t as usize]
                - last.iter().zip(c).map(|(l, c)| c*(i as i32 - l)).sum::<i32>()
            };
            last[t] = pre_last;
            if best_satification < tmp_satification {
                best_contest = t;
                best_satification = tmp_satification;
            }
        }
        satification = best_satification;
        last[best_contest] = i;
        contests[(i-1) as usize] = best_contest;
        // println!("{}", best_contest+1);
    }
    BestResult{
        satification,
        contests
    }
}

fn local_search(d: i32, c: &Vec<i32>, s: &Vec<Vec<i32>>, contests: &mut Vec<usize>, start: Instant) -> i32 {
    let mut all_change = 0i32;
    let limit = Duration::from_millis(1900);
    let mut rng = SmallRng::from_entropy();
    while Instant::now() - start < limit {
        let day = rng.gen_range(0, d) as usize;
        let changed_contest = rng.gen_range(0, 26);
        let mut change = -s[day][contests[day]];
        // 変更する操作を無かったことにするための差分
        change += match contests[day..d as usize]
                        .iter()
                        .position(|x| *x == contests[day]) {
            Some(x) => c[contests[day]]*(x as i32 - day as i32 + 1),
            None => match contests[..day as usize]
                        .iter().rev()
                        .position(|x| *x == contests[day]) {
                Some(x) => c[contests[day]]*(day as i32 - x as i32 + 1) as i32,
                None => c[changed_contest] * (day + 1) as i32
                }
        };
        // 変更後の差分
        change += s[day][changed_contest];
        change -= match contests[day+1..d as usize]
                        .iter()
                        .position(|x| *x == changed_contest) {
            Some(x) => c[changed_contest]*(x as i32 - day as i32 + 1) as i32,
            None => 0
        };
        change -= match contests[..day as usize]
                        .iter().rev()
                        .position(|x| *x == contests[day]) {
            Some(x) => c[changed_contest]*(day as i32 - x as i32 + 1) as i32,
            None => c[changed_contest] * (day + 1) as i32
        };

        if change > 0 {
            contests[day] = changed_contest;
            all_change += change;
        };
    }
    return all_change
}

Measured memory_bytes: 2256