#![allow(unused_imports)]
#![allow(unused_macros)]
use rand;
use rand::Rng;
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};
use std::time::{Duration, SystemTime};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

const K: usize = 26;

#[derive(Debug)]
struct Input {
    d: usize,
    c: Vec<i64>,
    s: Vec<Vec<i64>>,
}

fn get_input<'a>(it: &mut impl Iterator<Item = &'a str>) -> Input {
    parse!(it, d: usize, c: [i64; K]);
    let mut s = vec![];
    for _ in 0..d {
        parse!(it, sl: [i64; K]);
        s.push(sl);
    }
    Input { d, c, s }
}

#[derive(Debug)]
struct State<'a> {
    out: Vec<usize>,
    score: i64,
    ds: Vec<Vec<usize>>,
    input: &'a Input,
}

impl<'a> State<'a> {
    fn new(input: &'a Input, out: Vec<usize>) -> Self {
        calc_score(input, out)
    }
    fn change(&mut self, d: usize, q: usize) {
        // remove p
        let p = self.out[d];
        self.score -= self.input.s[d][p];
        let i = self.ds[p].iter().position(|&x| x == d).unwrap();
        let l = i.checked_sub(1).map(|i| self.ds[p][i]);
        let r = self.ds[p][i + 1];
        self.score -= change_penalty(l, r, d, self.input.c[p]);
        self.ds[p].remove(i);

        // replace to q
        self.score += self.input.s[d][q];
        self.out[d] = q;
        let i = self.ds[q].iter().position(|&x| x > d).unwrap();
        self.ds[q].insert(i, d);
        let l = i.checked_sub(1).map(|i| self.ds[q][i]);
        let r = self.ds[q][i + 1];
        self.score += change_penalty(l, r, d, self.input.c[q]);
    }
}

fn change_penalty(l: Option<usize>, r: usize, p: usize, c: i64) -> i64 {
    assert!(p < r);
    assert!(l == None && p < r || l.unwrap() < p && p < r);
    let mut ret = calc_penalty(l, r, c);
    ret -= calc_penalty(l, p, c);
    ret -= calc_penalty(Some(p), r, c);
    ret
}

fn calc_penalty(prev: Option<usize>, v: usize, c: i64) -> i64 {
    let d = if let Some(prev) = prev {
        v - prev
    } else {
        v + 1
    };
    (d * (d - 1) / 2) as i64 * c
}

fn calc_score(input: &Input, out: Vec<usize>) -> State {
    let mut score = 0;
    let mut ds = vec![vec![]; K];
    for i in 0..out.len() {
        score += input.s[i][out[i]];
        ds[out[i]].push(i);
    }
    for v in ds.iter_mut() {
        v.push(out.len())
    }
    for (q, set) in ds.iter().enumerate() {
        let mut prev: Option<usize> = None;
        for &v in set {
            score -= calc_penalty(prev, v, input.c[q]);
            prev = Some(v);
        }
    }
    State {
        out,
        score,
        ds,
        input,
    }
}

fn solve(s: &str) {
    let start = SystemTime::now();
    let tl = Duration::new(1, 900000);
    let mut it = s.split_whitespace();
    let input = get_input(&mut it);
    let mut rng = rand::thread_rng();
    let t: Vec<usize> = (0..input.d).map(|_| rng.gen_range(0, K)).collect();
    let mut state = State::new(&input, t);
    const T0: f64 = 1000.;
    const T1: f64 = 100.;
    let mut t = T0;
    for i in 1.. {
        if i % 100 == 0 {
            let now = SystemTime::now();
            if now >= start + tl {
                break;
            }
            let s = now.duration_since(start).unwrap().as_nanos() as f64 / tl.as_nanos() as f64;
            t = T0.powf(1. - s) * T1.powf(s);
        }
        let d = rng.gen_range(0, input.d);
        let q = rng.gen_range(0, K);
        let p = state.out[d];
        let old_score = state.score;
        state.change(d, q);
        let dscore = state.score - old_score;
        let should_change = dscore >= 0 || rng.gen_bool((dscore as f64 / t).exp());
        if !should_change {
            state.change(d, p);
        }
    }
    for d in state.out {
        println!("{}", d + 1);
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 3432