#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
    ($($t:tt)*) => {{
        use ::std::io::Write;
        let _ = write!(::std::io::stderr(), $($t)*);
    }};
}
macro_rules! eprintln {
    () => { eprintln!(""); };
    ($($t:tt)*) => {{
        use ::std::io::Write;
        let _ = writeln!(::std::io::stderr(), $($t)*);
    }};
}
macro_rules! dbg {
    ($v:expr) => {{
        let val = $v;
        eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
        val
    }}
}

macro_rules! mat {
    ($($e:expr),*) => { Vec::from(vec![$($e),*]) };
    ($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
    ($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
    ($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
    ($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
        $a$([$i])*.$f($($t),*)
    };
    ($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
        let t = $e;
        ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
    } };
}

pub fn readln() -> String {
    let mut line = String::new();
    ::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
    line
}

macro_rules! read {
    ($($t:tt),*; $n:expr) => {{
        let stdin = ::std::io::stdin();
        let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
            let line = line.unwrap();
            let mut it = line.split_whitespace();
            _read!(it; $($t),*)
        }).collect::<Vec<_>>();
        ret
    }};
    ($($t:tt),*) => {{
        let line = readln();
        let mut it = line.split_whitespace();
        _read!(it; $($t),*)
    }};
}

macro_rules! _read {
    ($it:ident; [char]) => {
        _read!($it; String).chars().collect::<Vec<_>>()
    };
    ($it:ident; [u8]) => {
        Vec::from(_read!($it; String).into_bytes())
    };
    ($it:ident; usize1) => {
        $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
    };
    ($it:ident; [usize1]) => {
        $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
    };
    ($it:ident; [$t:ty]) => {
        $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
    };
    ($it:ident; $t:ty) => {
        $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
    };
    ($it:ident; $($t:tt),+) => {
        ($(_read!($it; $t)),*)
    };
}


pub fn main() {
    let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 1_000_000_007;
const INF: i64 = std::i64::MAX/3;

const TIME_LIMIT: f64 = 2.0;

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 XorShift {
	pub x: [u32; 4]
}

impl XorShift {
	pub fn new(mut seed: u32) -> XorShift {
		let mut x = [0; 4];
		for i in 0..4 {
			seed = 1812433253u32.wrapping_mul(seed ^ (seed >> 30)).wrapping_add(i as u32);
			x[i] = seed;
		}
		XorShift { x: x }
	}
	pub fn next32(&mut self) -> usize {
		let t = self.x[0] ^ (self.x[0] << 11);
		for i in 0..3 { self.x[i] = self.x[i + 1] }
		self.x[3] = self.x[3] ^ (self.x[3] >> 19) ^ t ^ (t >> 8);
		self.x[3] as usize
	}
	/// [0, n)
	pub fn next(&mut self, n: usize) -> usize {
		loop {
			let t = self.next32();
			let r = t % n;
			if (t - r).checked_add(n).is_some() {
				return r;
			}
		}
	}
}

fn solve() {
    let start_time = get_time();
    let d = read!(usize);
    let c = read!([i64]);
    let s = read!([i64];d);
    let mut contests = vec![0;d];
    let mut dict = vec![vec![vec![0,d+1];d+2];26];
    let mut prev = vec![0;26];

    let mut log = vec![0.0;131072];
    for i in 0..log.len() {
        log[i] = ((i as f64 + 0.5)/log.len() as f64).log2();
    }

    let mut rng = XorShift::new(583290);

    for i in 0..d {
        let mut ma = (0,i);
        for j in 0..26 {
            if s[i][j] > ma.0 {
                ma = max(ma, (s[i][j],j));
            }
        }
        contests[i] = ma.1;
    }
    for i in 0..d {
        let idx = contests[i];
        dict[idx][i+1][0] = prev[idx];
        dict[idx][prev[idx]][1] = i+1;
        prev[idx] = i+1;
    }
    for i in 0..26 {
        dict[i][d+1][0] = prev[i];
    }
    let mut score = 0;
    for i in 0..d {
        score += s[i][contests[i]];
    }
    for i in 0..26 {
        let mut idx = 0;
        let mut sum = 0_i64;
        loop {
            let nxt = dict[i][idx][1];
            sum += calc_diff_sum(idx, nxt);
            if nxt==d+1 {
                break;
            }
            idx = nxt;
        }
        score -= sum*c[i];
    }

    let mut t = get_time()-start_time;
    let mut count = 0;
    let tl = TIME_LIMIT*0.97;
    let mut rem = 0.0;
	let K = 0.005;
	loop {
        count += 1;
		if (count & 255) == 0 {
			t = get_time()-start_time;
			if t >= tl {break;}
			rem = (tl as f64 - t as f64) * K / tl as f64;
        }
        if count%2==0{
            let t_day = rng.next(d);
            let t_idx = rng.next(26);
            let s_idx = contests[t_day];
            if t_idx==s_idx {
                continue;
            }
            let mut prev_score = score;
            score += s[t_day][t_idx];
            score -= s[t_day][s_idx];
            let prev_sidx = dict[s_idx][t_day+1][0];
            let after_sidx = dict[s_idx][t_day+1][1];
            score += (calc_diff_sum(prev_sidx, t_day+1)+calc_diff_sum(t_day+1, after_sidx))*c[s_idx];
            score -= (calc_diff_sum(prev_sidx, after_sidx))*c[s_idx];
            let mut prev_tidx = 0;
            loop {
                let nxt = dict[t_idx][prev_tidx][1];
                if nxt > t_day+1 {
                    break;
                }
                prev_tidx = nxt;
            }
            let after_tidx = dict[t_idx][prev_tidx][1];
            score -= (calc_diff_sum(prev_tidx, t_day+1)+calc_diff_sum(t_day+1, after_tidx))*c[t_idx];
            score += (calc_diff_sum(prev_tidx, after_tidx))*c[t_idx];
            let gain = (score as f64 - prev_score as f64)/ (prev_score as f64).abs();
            if gain < log[rng.next(log.len())] * rem {
                score = prev_score;
                continue;
            }
            dict[s_idx][prev_sidx][1] = after_sidx;
            dict[s_idx][after_sidx][0] = prev_sidx;
            dict[s_idx][t_day+1][0] = 0;
            dict[s_idx][t_day+1][1] = d+1;
            dict[t_idx][prev_tidx][1] = t_day+1;
            dict[t_idx][after_tidx][0] = t_day+1;
            dict[t_idx][t_day+1][0] = prev_tidx;
            dict[t_idx][t_day+1][1] = after_tidx;
            contests[t_day] = t_idx;
        }
        else {
            let s_day = rng.next(d-1);
            let s_idx = contests[s_day];
            let t_day = s_day+1;
            let t_idx = contests[t_day];
            if s_idx==t_idx {
                continue;
            }
            let mut prev_score = score;
            score -= s[s_day][s_idx];
            score += s[s_day][t_idx];
            score -= s[t_day][t_idx];
            score += s[t_day][s_idx];
            let prev_sidx = dict[s_idx][s_day+1][0];
            let after_sidx = dict[s_idx][s_day+1][1];
            score += (calc_diff_sum(prev_sidx, s_day+1)+calc_diff_sum(s_day+1, after_sidx))*c[s_idx];
            score -= (calc_diff_sum(prev_sidx, t_day+1)+calc_diff_sum(t_day+1, after_sidx))*c[s_idx];
            let prev_tidx = dict[t_idx][t_day+1][0];
            let after_tidx = dict[t_idx][t_day+1][1];
            score += (calc_diff_sum(prev_tidx, t_day+1)+calc_diff_sum(t_day+1, after_tidx))*c[t_idx];
            score -= (calc_diff_sum(prev_tidx, s_day+1)+calc_diff_sum(s_day+1, after_tidx))*c[t_idx];
            let gain = (score as f64 - prev_score as f64)/ (prev_score as f64).abs();
            if gain < log[rng.next(log.len())] * rem {
                score = prev_score;
                continue;
            }
            dict[s_idx][prev_sidx][1] = t_day+1;
            dict[s_idx][after_sidx][0] = t_day+1;
            dict[s_idx][t_day+1][0] = prev_sidx;
            dict[s_idx][t_day+1][1] = after_sidx;
            dict[s_idx][s_day+1][0] = 0;
            dict[s_idx][s_day+1][1] = d+1;

            dict[t_idx][prev_tidx][1] = s_day+1;
            dict[t_idx][after_tidx][0] = s_day+1;
            dict[t_idx][s_day+1][0] = prev_tidx;
            dict[t_idx][s_day+1][1] = after_tidx;
            dict[t_idx][t_day+1][0] = 0;
            dict[t_idx][t_day+1][1] = d+1;
            contests[s_day] = t_idx;
            contests[t_day] = s_idx;
        }
    }
    print_ans(contests);
}

fn calc_diff_sum(s: usize, t: usize) -> i64{
    let diff = (t - s - 1) as i64;
    let val = (1+diff)*diff/2;
    val
}

fn print_ans(con: Vec<usize>) {
    for &i in &con {
        println!("{}",i+1);
    }
}

fn run() {
    solve();
}

Measured memory_bytes: 3516