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

struct Input {
    d: i32,
    c: Vec<i32>,
    s: Vec<Vec<i32>>
}

#[proconio::fastout]
fn main() {
    let start = Instant::now();
    input! {
        d: i32,
        c: [i32; 26],
        s: [[i32; 26]; d],
    }
    let input = Input{d, c, s};
    let state = State::from_greedy(&input);
    println!("{}", state);
    eprintln!("satification: {}", state.score);
    eprintln!("score: {}", std::cmp::max(10i32.pow(6)+state.score, 0));
}

struct State {
    score: i32,
    schedule : Vec<usize>,
    ds: Vec<Vec<usize>>
}

impl std::fmt::Display for State {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
       let s: String = self.schedule.iter()
                       .map(|x| (x+1).to_string())
                       .collect::<Vec<String>>()
                       .join("\n");
        write!(f, "{}", s)
    }
}

impl State {
    fn from_greedy(input: &Input) -> State {
        let mut score = 0;
        let mut ds: Vec<Vec<usize>> = vec![vec![]; 26];
        let mut schedule = vec![0; input.d as usize];
        let mut last = vec![0; 26];
        for i in 0..input.d {
            let mut best_contest: usize = 0;
            let mut best_satification = -1_000_000_000;
            for t in 0..26 {
                let pre_last = last[t];
                last[t] = i;
                let tmp_satification = {
                    score
                    + input.s[i as usize][t as usize]
                    - last.iter().zip(&input.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;
                }
            }
            score = best_satification;
            last[best_contest] = i;
            schedule[i as usize] = best_contest;
            ds[best_contest].push(i as usize);
            // println!("{}", best_contest+1);
        };
        State{score, schedule, ds}
    }
}

// fn add_contest(d: i32, c: &Vec<i32>, s: &Vec<Vec<i32>>, contests: &mut Vec<usize>, day: usize, contest: usize) -> i32 {
//     // 開催すると得られる満足度
//     let mut satification = s[day][contest];
//     // 新しく追加されたコンテストのためにこの後同じコンテストが合ったときの減少
//     satification -= match contests[day+1..d as usize]
//                           .iter()
//                           .position(|x| *x == contest) {
//         Some(x) => c[contest] * (x + 1) as i32,
//         None => 0
//     };
//     // 新しく追加したコンテストの減少
//     satification -= match contests[..day as usize]
//                     .iter().rev()
//                     .position(|x| *x == contests[day]) {
//         Some(x) => c[contest] * (x + 1) as i32,
//         None => c[contest] * (day + 1) as i32
//     };
// }
// fn greedy(input: &Input) -> BestResult {
//     let mut satification = 0;
//     let mut last: Vec<i32> = vec![0; 26];
//     let mut contests: Vec<usize> = vec![0; input.d as usize];
//     for i in 1..input.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
//                 + input.s[(i-1) as usize][t as usize]
//                 - last.iter().zip(&input.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
//     }
// }

Measured memory_bytes: 2312