using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Heuristics
{
    class Introduction
    {
        private static int GeneN = 500;

        private static int DayN;

        private static int ContestN = 26;

        private static int[] c;

        private static int[][] s;

        private static int sumC;

        class Gene
        {
            public int[] Program;
            public int[] Score;
            public Gene()
            {
                Program = new int[DayN + 1];
                Score = new int[DayN + 1];
            }

            public Gene(int[] program)
            {
                Program = program;
                Score = new int[program.Length];
            }
        }

        private static void Evaluate(List<Gene> generation)
        {
            foreach (var gene in generation)
            {
                int dec = 0;
                var last = new int[ContestN + 1];
                gene.Score[0] = 0;
                for (int i = 1; i <= DayN; i++)
                {
                    dec += sumC - (c[gene.Program[i]] * (i - last[gene.Program[i]]));
                    last[gene.Program[i]] = i;
                    gene.Score[i] = gene.Score[i - 1] - dec + s[i][gene.Program[i]];
                }
            }
        }

        public static void Main()
        {
            DayN = int.Parse(Console.ReadLine());
            c = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            sumC = c.Sum();


            s = new int[DayN + 1][];
            for (int i = 1; i <= DayN; i++)
                s[i] = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var generation = CreateFirstGeneration();
            Gene best = generation.First();


            Evaluate(generation);
            generation.Sort((a, b) =>
            {
                long diff = b.Score.Last() - a.Score.Last();
                return diff < 0 ? -1 : diff > 0 ? 1 : 0;
            });
            generation = generation.OrderByDescending(x => x.Score.Last()).ToList();
            if (best.Score.Last() < generation[0].Score.Last())
                best = generation[0];

            // update

            for (int i = 1; i <= DayN; i++)
                Console.WriteLine(best.Program[i] + 1);
        }

        private static List<Gene> CreateFirstGeneration()
        {
            var generation = new List<Gene>();
            var item = Enumerable.Range(0, DayN + 1).Select(x => x % ContestN).ToArray();
            generation.Add(new Gene(item));

            var random = new Random();
            var index = Enumerable.Range(0, ContestN).ToArray();
            for (int i = 0; i < GeneN - 1; i++)
            {
                Shuffle(index, random);
                generation.Add(new Gene(item.Select(x => index[x]).ToArray()));
            }
            return generation;
        }

        private static void Shuffle(int[] srcdst, Random rand)
        {
            int n = srcdst.Length;
            while (n > 1)
            {
                int k = rand.Next(n--);
                int temp = srcdst[k];
                srcdst[k] = srcdst[n];
                srcdst[n] = temp;
            }
        }
    }
}

Measured memory_bytes: 30728