use std::collections::BTreeSet;

fn main() {
    let d: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };
    let c: Vec<i64> = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let iter = buf.split_whitespace();
        iter.map(|x| x.parse().unwrap()).collect()
    };
    let mut s: Vec<Vec<i64>> = Vec::with_capacity(d);
    for _ in 0..d {
        let a: Vec<i64> = {
            let mut buf = String::new();
            std::io::stdin().read_line(&mut buf).unwrap();
            let iter = buf.split_whitespace();
            iter.map(|x| x.parse().unwrap()).collect()
        };
        s.push(a);
    }
    let s = s;

    let mut ord: Vec<usize> = Vec::with_capacity(d);
    let mut sets: Vec<BTreeSet<usize>> = vec![BTreeSet::new(); 26];
    let mut last: Vec<usize> = vec![0; 26];
    for i in 1..=d {
        let mut max_satisfy = std::i64::MIN;
        let mut max_type = 0;
        for t in 0..26 {
            let res = s[i - 1][t] + c[t] * (i - last[t]) as i64;
            if max_satisfy < res {
                max_satisfy = res;
                max_type = t;
            }
        }
        last[max_type] = i;
        ord.push(max_type);
        sets[max_type].insert(i);
    }

    for z in 1..5000 {
        for e in 1..=d {
            let q = e * 6174 % 26 * z % 26;
            let mut f = || {
                let mut satisfy = 0;
                let p: usize = ord[e - 1];
                if p == q { return 0; }
                match sets[p].range((e + 1)..).next() {
                    Some(x) => {
                        match sets[p].range(..(e)).rev().next() {
                            Some(y) => {
                                satisfy -= c[p] * ((e - y) * (x - e)) as i64;
                            },
                            None => {
                                satisfy -= c[p] * (e * (x - e)) as i64;
                            },
                        }
                    },
                    None => {
                        match sets[p].range(..(e)).rev().next() {
                            Some(y) => {
                                satisfy -= c[p] * ((e - y) * (d + 1 - e)) as i64;
                            },
                            None => {
                                satisfy -= c[p] * (e * (d + 1 - e)) as i64;
                            },
                        }
                    }
                }
                sets[p].remove(&e);
                satisfy -= s[e - 1][p];
        
                match sets[q].range((e + 1)..).next() {
                    Some(x) => {
                        match sets[q].range(..(e)).rev().next() {
                            Some(y) => {
                                satisfy += c[q] * ((e - y) * (x - e)) as i64;
                            },
                            None => {
                                satisfy += c[q] * (e * (x - e)) as i64;
                            },
                        }
                    },
                    None => {
                        match sets[q].range(..e).rev().next() {
                            Some(y) => {
                                satisfy += c[q] * ((e - y) * (d + 1 - e)) as i64;
                            },
                            None => {
                                satisfy += c[q] * (e * (d + 1 - e)) as i64;
                            },
                        }
                    }
                }
                sets[q].insert(e);
                satisfy += s[e - 1][q];
        
                satisfy
            };    
            let satisfy = f();
            if satisfy > 0 {
                ord[e - 1] = q;
            }
        }    
    }

    for t in ord {
        println!("{}", t + 1);
    }
}

Measured memory_bytes: 2376