//#define NO_LOCAL
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace Program
{
    /* 提出前に REPEATAS = 1 を確認！ */
    public class Program
    {
        int D = 365;
        int[] c;
        int[,] s;
        private const int LIMIT_OFFSET = 80, REPEATS = 1;
        public const string IN_TXT = "in1.txt";

        private void Solve() {
            var res = new sbyte[D];
            for (int i = 0; i < D; i++) {
                res[i] = (sbyte) (i % 26 + 1);
            }

            long score = Eval(res);
            var firstScore = score;
            Console.Error.WriteLine("FirstScore: " + score);
            int count = 0;
            while (stopwatch.ElapsedMilliseconds <= Limit) {
                ++count;
                short a = (short) rand.Next(D), b;
                do {
                    b = (short) rand.Next(D);
                } while (res[a] == res[b]);

                sbyte ai = res[a], bi = res[b];
                
                int tmpA = Change(res, a, bi);
                res[a] = bi;
                int tmpB = Change(res, b, ai);
                int scoreDiff = tmpA + tmpB;
                // 現在のスコア の 残り時間の割合/10
                bool flag = scoreDiff > 0;
                if (scoreDiff <= 0) {
                    var x = 1 - stopwatch.ElapsedMilliseconds / (double) Limit;
                    flag |= -scoreDiff < score * x;
                }
                
                if (scoreDiff > 0) {
                    res[b] = ai;
                    var eval = Eval(res);
                    if (score + scoreDiff != eval) {
                        Console.Error.WriteLine("!");
                    }

                    score += scoreDiff;
                } else {
                    res[a] = ai;
                    continue;
                }
            }

            Console.Error.WriteLine($"Count: {count}");
            Console.Error.WriteLine($"Score: {score} (+{score - firstScore})");
            Console.Error.WriteLine($"Eval: {Eval(res)}");
            sw.WriteLine(string.Join("\n", res));
        }

        // ReSharper disable once SuggestBaseTypeForParameter
        private int Eval(sbyte[] res) {
            var last = new short[26];
            int result = 0;
            for (short d = 1; d <= D; ++d) {
                var i = res[d - 1] - 1;
                result += s[d - 1, i];
                last[i] = d;
                for (sbyte j = 0; j < 26; j++) {
                    result -= c[j] * (d - last[j]);
                }
            }

            return result;
        }

        private int Change(sbyte[] res, short d, sbyte to) {
            // スコアの差分を求める
            int from = res[d] - 1;
            --to;

            var result = s[d, to] - s[d, from];
            short pLast = -1, qLast = -1;
            for (short i = (short)(d - 1); i >= 0; --i) {
                if (pLast == -1 && res[i] - 1 == from) {
                    pLast = i;
                } else if (qLast == -1 && res[i] - 1 == to) {
                    qLast = i;
                }

                if (pLast >= 0 && qLast >= 0) break;
            }

            // last(p) が pLast に変わる
            // last(q) が d に変わる
            bool foundP = false, foundQ = false;
            for (short i = d; i < D; i++) {
                if (i > d && res[i] - 1 == from) foundP = true;
                if (i > d &&res[i] - 1 == to) foundQ = true;
                if (!foundP) {
                    result += c[from] * (i - d);
                    result -= c[from] * (i - pLast);
                }

                if (!foundQ) {
                    result += c[to] * (i - qLast);
                    result -= c[to] * (i - d);
                }
            }
            return result;
        }

        private void Input() {
            D = ReadInt;
            c = ReadIntArray;
            s = new int[D, 26];
            for (int i = 0; i < D; i++) {
                var tmp = ReadIntArray;
                for (int j = 0; j < 26; j++) s[i, j] = tmp[j];
            }
        }

        private void Output() { }



        /* 以下テンプレート等 */

        #region

        private readonly int Limit;
        private readonly Random rand;
        private StreamWriter sw;
        private readonly Stopwatch stopwatch;

        public Program(int limit) {
            stopwatch = new Stopwatch();
            rand = new Random();
            Limit = limit;
        }

        public void Main() {
#if LOCAL && !NO_LOCAL
            sw = new StreamWriter("out.txt");
            sr = new StreamReader(IN_TXT);
#else
            sw = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
            Console.SetOut(sw);
#endif
            stopwatch.Start();
            Input();
            Solve();
            Output();
            sw.Flush();
#if LOCAL && !NO_LOCAL
            sw.Dispose();
            /*
            using (var r = new StreamReader("out.txt"))
            {
                while (!r.EndOfStream)
                {
                    Console.WriteLine(r.ReadLine());
                }
            }*/
#endif
        }

        public static void Main(string[] args) {
            int limit = 2000 - LIMIT_OFFSET;
//            if (args.Any()) limit *= 2;
            for (int i = 0; i < REPEATS; i++) {
                new Program(limit).Main();
#if !LOCAL
break;
#endif
            }
        }

        public void Debug(object o) {
#if LOCAL
            Console.WriteLine(o);
#endif
        }

        private StreamReader sr;

        public string ReadLine {
            get {
#if LOCAL && !NO_LOCAL
                return sr.ReadLine();
#else
                return Console.ReadLine();
#endif
            }
        }

        public string[] ReadArray => ReadLine.Split(' ');
        public int[] ReadIntArray => ReadArray.Select(int.Parse).ToArray();
        public int ReadInt => int.Parse(ReadLine);

        #endregion
    }
}


Measured memory_bytes: 29212