use proconio::input;
use std::iter::once;

const ALPHA: usize = 26;

#[derive(Debug, Clone)]
struct Contest {
    pub miss: i64,
    pub happiness: Vec<i64>,
    pub schedule: Vec<bool>,
}

impl Contest {
    fn with_args(miss: i64, happiness: Vec<i64>, schedule: Vec<bool>) -> Self {
        Self {
            miss,
            happiness,
            schedule,
        }
    }

    #[allow(dead_code)]
    fn day_score(&self, d: usize) -> i64 {
        if self.schedule[d] {
            self.happiness[d]
        } else {
            -(self.prev(d) as i64) * self.miss
        }
    }

    fn score(&self) -> i64 {
        self.happiness
            .iter()
            .zip(self.schedule.iter())
            .scan(0, |state, (&h, &s)| {
                Some(if s {
                    *state = 0;
                    h
                } else {
                    *state += 1;
                    -self.miss * *state
                })
            })
            .sum()
    }

    fn prev(&self, d: usize) -> usize {
        self.schedule[0..=d]
            .iter()
            .rev()
            .copied()
            .chain(once(true))
            .take_while(|x| !x)
            .count()
    }

    fn next(&self, d: usize) -> usize {
        self.schedule[d..self.schedule.len()]
            .iter()
            .copied()
            .chain(once(true))
            .take_while(|x| !x)
            .count()
    }

    fn retropeek(&self, d: usize) -> i64 {
        assert!(!self.schedule[d]);
        self.happiness[d] - (self.prev(d) as i64) * (self.next(d) as i64) * self.miss
    }

    fn peek_slow(&self, d: usize) -> i64 {
        assert!(!self.schedule[d]);
        self.happiness[d] - (self.prev(d) as i64) * (self.next(d) as i64) * self.miss
    }

    fn unset_slow(&mut self, d: usize) -> i64 {
        assert!(self.schedule[d]);
        self.schedule[d] = false;
        -self.peek_slow(d)
    }

    fn set_slow(&mut self, d: usize) -> i64 {
        let ret = self.peek_slow(d);
        assert!(!self.schedule[d]);
        self.schedule[d] = true;
        ret
    }
}

fn main() {
    input!(dmax: usize, c: [i64; ALPHA], s: [[i64; ALPHA]; dmax],);

    let mut contests: Vec<_> = (0..ALPHA)
        .map(|i| {
            let c = Contest::with_args(
                c[i],
                s.iter().map(|row| row[i]).collect(),
                vec![false; dmax],
            );
            c
        })
        .collect();

    let mut score = 0;
    let mut t = (0..dmax).map(|d| {
        let i = (0..ALPHA)
            .map(|i| (contests[i].happiness[d], i))
            .max()
            .unwrap()
            .1;
        contests[i].set_slow(d);
        i
    });

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

#[cfg(test)]
mod test {
    use super::*;

    #[test]
    fn test_day_score() {
        let miss = 4;
        let happiness = vec![10, 20, -10, 20, 0];
        let schedule = vec![false, false, true, true, false];
        let contest = Contest {
            miss,
            happiness,
            schedule,
        };
        assert_eq!(contest.day_score(0), -4);
        assert_eq!(contest.day_score(1), -8);
        assert_eq!(contest.day_score(2), -10);
        assert_eq!(contest.day_score(3), 20);
        assert_eq!(contest.day_score(4), -4);
    }

    #[test]
    fn test_score() {
        let dmax = 5;
        let miss = 4;
        let happiness = vec![10, 20, -10, 20, 0];
        let schedule = vec![false, false, true, true, false];
        let contest = Contest {
            miss,
            happiness,
            schedule,
        };
        assert_eq!(
            contest.score(),
            (0..dmax).map(|d| contest.day_score(d)).sum()
        );
    }

    #[test]
    fn test_unset_set_peek_slow() {
        let miss = 4;
        let happiness = vec![10, 20];
        let schedule = vec![true, true];
        let mut contest = Contest {
            miss,
            happiness,
            schedule,
        };
        assert_eq!(contest.unset_slow(1), -16);
        assert_eq!(contest.peek_slow(1), 16);
        assert_eq!(contest.set_slow(1), 16);
    }
}


Measured memory_bytes: 2404