#![allow(non_snake_case)]

use std::io::Read;

use rand::prelude::*;

const ALPHA_SIZE: usize = 26;
const TIME_LIMIT: f64 = 1.8;

pub trait SetMinMax {
    fn set_min(&mut self, v: Self) -> bool;
    fn set_max(&mut self, v: Self) -> bool;
}

impl<T> SetMinMax for T where T: PartialOrd {
    fn set_min(&mut self, v: Self) -> bool {
        *self > v && {
            *self = v;
            true
        }
    }

    fn set_max(&mut self, v: Self) -> bool {
        *self < v && {
            *self = v;
            true
        }
    }
}

struct Timer {
    start_time: f64
}

fn get_time_sec() -> f64 {
    let t = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap();
    t.as_secs() as f64 + t.subsec_nanos() as f64 * 1e-9
}

impl Timer {
    fn new() -> Timer {
        Timer {
            start_time: get_time_sec()
        }
    }

    fn get_elapsed_time_sec(self: &Self) -> f64 {
        get_time_sec() - self.start_time
    }
}


#[derive(Clone)]
struct State<'a> {
    D: usize,
    C: &'a Vec<i32>,
    S: &'a Vec<Vec<i32>>,
    actions: Vec<usize>,
}


impl<'a> State<'a> {
    fn create(D: usize, C: &'a Vec<i32>, S: &'a Vec<Vec<i32>>, actions: Vec<usize>) -> State<'a> {
        assert_eq!(actions.len(), D);
        assert_eq!(S[0].len(), ALPHA_SIZE);
        return State { D, C, S, actions };
    }

    fn score(self: &Self) -> i32 {
        let mut score = 0;
        let mut last: Vec<i32> = vec![-1; ALPHA_SIZE];
        for d in 0..self.actions.len() {
            let diff = d as i32 - last[self.actions[d]];
            score += self.S[d][self.actions[d]];
            score -= diff * (diff - 1) / 2 * self.C[self.actions[d]];
            last[self.actions[d]] = d as i32;
        }
        for c in 0..ALPHA_SIZE {
            let diff = self.actions.len() as i32 - last[c];
            score -= diff * (diff - 1) / 2 * self.C[c]
        }
        score
    }


    fn change_action(self: &mut Self, date: usize, action: usize) {
        self.actions[date] = action
    }

    fn swap_actions(self: &mut Self, d1: usize, d2: usize) {
        let action = self.actions[d1];
        self.actions[d1] = self.actions[d2];
        self.actions[d2] = action;
    }
}

struct Solver {
    D: usize,
    C: Vec<i32>,
    S: Vec<Vec<i32>>,
    timer: Timer,
}

impl Solver {
    fn create() -> Solver {
        let mut buffer = String::new();
        std::io::stdin().read_to_string(&mut buffer).unwrap();
        let mut iter = buffer.split_whitespace();
        let D = iter.next().unwrap().parse::<usize>().unwrap();

        let C: Vec<i32> = (0..ALPHA_SIZE)
            .map(|_| iter.next().unwrap().parse::<i32>().unwrap())
            .collect();
        let S: Vec<Vec<i32>> = (0..D)
            .map(|_| {
                (0..ALPHA_SIZE)
                    .map(|_| iter.next().unwrap().parse::<i32>().unwrap())
                    .collect()
            })
            .collect();
        Solver { D, C, S, timer: Timer::new() }
    }

    fn hill_climbing(self: &Self, start_state: Vec<usize>) -> Vec<usize> {
        let mut state = State::create(self.D, &self.C, &self.S, start_state);
        let mut update_count = 0;
        let mut best_score = state.score();
        while self.timer.get_elapsed_time_sec() < TIME_LIMIT {
            for d in 0..self.D {
                for a in 0..ALPHA_SIZE {
                    let curr_actoin = state.actions[d];
                    state.change_action(d, a);
                    let new_score = state.score();
                    if best_score.set_max(new_score) {
                        eprintln!("[{}: Modify] Change the best score to {} (time = {})",
                                  update_count, best_score, self.timer.get_elapsed_time_sec());
                        update_count += 1;
                    } else {
                        state.change_action(d, curr_actoin)
                    }
                }
            }

            for d in 0..self.D - 1 {
                state.swap_actions(d, d + 1);
                let new_score = state.score();
                if best_score.set_max(new_score) {
                    eprintln!("[{}: Swap] Change the best score to {} (time = {})",
                              update_count, best_score, self.timer.get_elapsed_time_sec());
                    update_count += 1;
                } else {
                    state.swap_actions(d, d + 1)
                }
            }
        }
        state.actions
    }

    fn annealing(self: &Self, start_state: Vec<usize>) -> Vec<usize> {
        let mut rng = rand_pcg::Pcg64Mcg::new(1);
        let mut state = State::create(self.D, &self.C, &self.S, start_state);
        let mut update_count = 0;
        let mut best_score = state.score();
        let swap_prob = 0.5;
        while self.timer.get_elapsed_time_sec() < TIME_LIMIT {
            if rng.gen_bool(swap_prob) {
                let d = rng.gen_range(0, self.D - 1);
                state.swap_actions(d, d + 1);
                let new_score = state.score();
                if best_score.set_max(new_score) {
                    eprintln!("[{}: Swap] Change the best score to {} (time = {})",
                              update_count, best_score, self.timer.get_elapsed_time_sec());
                    update_count += 1;
                } else {
                    state.swap_actions(d, d + 1)
                }
            } else {
                let d = rng.gen_range(0, self.D);
                let a = rng.gen_range(0, ALPHA_SIZE);
                let curr_action = state.actions[d];
                state.change_action(d, a);
                let new_score = state.score();
                if best_score.set_max(new_score) {
                    eprintln!("[{}: Modify] Change the best score to {} (time = {})",
                              update_count, best_score, self.timer.get_elapsed_time_sec());
                    update_count += 1;
                } else {
                    state.change_action(d, curr_action)
                }
            }
        }
        state.actions
    }

    pub fn solve(self: &Self) -> Vec<usize> {
        let mut rng = rand_pcg::Pcg64Mcg::new(1);
        let mut start_actions = (0..self.D).map(|_| rng.gen_range(0, ALPHA_SIZE)).collect();
        self.annealing(start_actions)
    }
}

fn main() {
    let solver = Solver::create();
    for action in solver.solve() {
        println!("{}", action + 1);
    }
}


Measured memory_bytes: 2288