#[macro_export]
macro_rules !read_value {($iter :expr ,($($t :tt ) ,*) ) =>{($(read_value !($iter ,$t ) ) ,*) } ;($iter :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($iter ,$t ) ) .collect ::<Vec <_ >>() } ;($iter :expr ,{$t :tt =>$f :expr } ) =>{$f (read_value !($iter ,$t ) ) } ;($iter :expr ,chars ) =>{read_value !($iter ,String ) .chars () .collect ::<Vec <char >>() } ;($iter :expr ,usize1 ) =>{read_value !($iter ,usize ) -1 } ;($iter :expr ,$t :ty ) =>{$iter .next () .unwrap () .parse ::<$t >() .unwrap () } ;}
#[macro_export]
macro_rules !input_inner {($iter :expr ) =>{} ;($iter :expr ,) =>{} ;($iter :expr ,mut $var :ident :$t :tt $($r :tt ) *) =>{let mut $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;($iter :expr ,mut $var :ident $($r :tt ) *) =>{input_inner !{$iter ,mut $var :usize $($r ) *} } ;($iter :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($iter ,$t ) ;input_inner !{$iter $($r ) *} } ;($iter :expr ,$var :ident $($r :tt ) *) =>{input_inner !{$iter ,$var :usize $($r ) *} } ;}
#[macro_export]
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;(iter =$iter :ident ,$($r :tt ) *) =>{let s ={use std ::io ::Read ;let mut s =String ::new () ;std ::io ::stdin () .read_to_string (&mut s ) .unwrap () ;s } ;let mut $iter =s .split_whitespace () ;input_inner !{$iter ,$($r ) *} } ;($($r :tt ) *) =>{let s ={use std ::io ::Read ;let mut s =String ::new () ;std ::io ::stdin () .read_to_string (&mut s ) .unwrap () ;s } ;let mut iter =s .split_whitespace () ;input_inner !{iter ,$($r ) *} } ;}
#[derive(Clone, Debug)]
pub struct Xorshift {
    y: u64,
}
impl Xorshift {
    pub fn new(seed: u64) -> Self {
        Xorshift { y: seed }
    }
    pub fn time() -> Self {
        let seed = std::time::SystemTime::now()
            .duration_since(std::time::UNIX_EPOCH)
            .ok()
            .unwrap_or_default()
            .as_secs() as u64;
        Xorshift::new(seed)
    }
    #[inline]
    pub fn next(&mut self) -> u64 {
        self.y ^= self.y << 5;
        self.y ^= self.y >> 17;
        self.y ^= self.y << 11;
        self.y
    }
    #[inline]
    pub fn rand(&mut self, k: u64) -> u64 {
        self.next() % k
    }
    #[inline]
    pub fn rands(&mut self, k: u64, n: usize) -> Vec<u64> {
        (0..n).map(|_| self.rand(k)).collect::<Vec<_>>()
    }
    #[inline]
    pub fn randf(&mut self) -> f64 {
        const UPPER_MASK: u64 = 0x3FF0000000000000;
        const LOWER_MASK: u64 = 0xFFFFFFFFFFFFF;
        let tmp = UPPER_MASK | (self.next() & LOWER_MASK);
        let result: f64 = unsafe { std::mem::transmute(tmp) };
        result - 1.0
    }
}
use std::time::SystemTime;
fn main() {
    #[allow(unused_imports)]
    use std::io::Write as _;
    let __out = std::io::stdout();
    #[allow(unused_mut, unused_variables)]
    let mut __out = std::io::BufWriter::new(__out.lock());
    #[allow(unused_macros)]
    macro_rules !print {($($arg :tt ) *) =>(::std ::write !(__out ,$($arg ) *) .unwrap () ) }
    #[allow(unused_macros)]
    macro_rules !println {($($arg :tt ) *) =>(::std ::writeln !(__out ,$($arg ) *) .unwrap () ) }
    #[allow(unused_macros)]
    macro_rules! echo {
        ($iter :expr ) => {
            echo!($iter, "\n")
        };
        ($iter :expr ,$sep :expr ) => {
            let mut iter = $iter;
            if let Some(item) = iter.next() {
                print!("{}", item);
            }
            for item in iter {
                print!("{}{}", $sep, item);
            }
            println!();
        };
    }
    const S: usize = 26;
    const T: f32 = 1.99;
    const D: usize = 365;
    input!(_d, c: [i64; S], s: [[i64; S]; D]);
    let mut rand = Xorshift::time();
    let mut it_c = 0;
    let mut t; // = Duration::new(0, 0);
    let mut best: Vec<_> = (0..D).map(|_| rand.rand(S as u64) as usize).collect();
    let calc = |x, cur: &Vec<_>| {
        let mut last = 0;
        let mut cs = 0;
        for (i, &y) in cur.iter().enumerate() {
            if x == y {
                last = i as i64 + 1;
            }
            cs += c[x] * last;
        }
        cs
    };
    let mut best_score = {
        let mut cs = 0i64;
        for (i, &x) in best.iter().enumerate() {
            cs += s[i][x];
            for j in 0..S {
                cs -= c[j] * (i as i64 + 1);
            }
        }
        for j in 0..S {
            cs += calc(j, &best);
        }
        cs
    };
    let now = SystemTime::now();
    loop {
        it_c += 1;
        if it_c % 100 == 0 {
            t = now.elapsed().unwrap();
            if t.as_secs_f32() > T {
                eprintln!("it_c = {:?}", it_c);
                break;
            }
        }
        let n = rand.rand(D as u64) as usize;
        let mut cur_score = best_score;

        let old = best[n];
        let mut nxt = old;
        while nxt == old {
            nxt = rand.rand(S as u64) as usize;
        }

        {
            cur_score -= s[n][old];
            cur_score -= calc(old, &best);
            cur_score -= calc(nxt, &best);
        }
        best[n] = nxt;
        {
            cur_score += s[n][nxt];
            cur_score += calc(old, &best);
            cur_score += calc(nxt, &best);
        }
        if best_score < cur_score {
            best_score = cur_score;
        } else {
            best[n] = old;
        }
        // else {
        //     let tp = 1000000. * (1. - t.as_secs_f32() / T);
        //     let p = ((best_score - cur_score) as f32 / tp).exp();
        //     if p > rand.randf() as f32 {
        //         best = cur;
        //         best_score = cur_score;
        //     }
        // }
    }
    echo!(best.into_iter().map(|x| x + 1));
}


Measured memory_bytes: 2348