// USING ON -----

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

// USING OFF -----
// USING ON -----

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Marathon;

// USING OFF -----
// USING ON -----

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Xsl.Runtime;

// USING OFF -----
// USING ON -----

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

// USING OFF -----
// CONTENT ON -----

// CONTENT OFF -----
// CONTENT ON -----

#region Utility

namespace Marathon.Problem
{
    /// <summary>
    /// ロギング
    /// </summary>
    public class Logger
    {
        public bool Verbose;
        private StreamWriter streamWriter;

        public Logger(bool verbose, string path = @"result/log.log")
        {
            Verbose = verbose;
            if (Verbose)
            {
                System.IO.Directory.CreateDirectory(Path.GetDirectoryName(path));
                streamWriter = new StreamWriter(path);
            }
        }

        public void Fatal(string message)
        {
            Console.Error.WriteLine(message);
            if(streamWriter != null)
                streamWriter.WriteLine(message);
        }

        public void Info(string message)
        {
            if (Verbose)
            {
                Console.Error.WriteLine(message);
                streamWriter.WriteLine(message);
            }
        }

        public void Debug(string message)
        {
            if (Verbose)
            {
                streamWriter.WriteLine(message);
            }
        }

        public void Close()
        {
            if (Verbose)
            {
                if (streamWriter != null)
                    streamWriter.Close();
            }
        }
    }

    
    /// <summary>
    /// 時間計測 
    /// </summary>
    public class Timer
    {
        private long StartTime;

        public static long NowUnixTime()
        {
            return new DateTimeOffset(DateTime.Now).ToUnixTimeMilliseconds();
        }

        public void Start()
        {
            StartTime = NowUnixTime();
        }

        public long Elapsed
        {
            get { return NowUnixTime() - StartTime; }
        }
    }

    /// <summary>
    /// プロファイリング目的の時間計測 
    /// </summary>

    public class TimerStat
    {
        
        List<long> sum = new List<long>();
        List<long> start = new List<long>();

        public void Start(int i)
        {
            if (Runner.MEASURE_TIME)
            {
                while (sum.Count() <= i)
                {
                    sum.Add(0L);
                    start.Add(0L);
                }

                start[i] = Timer.NowUnixTime();
            }
        }

        public void Stop(int i)
        {
            if (Runner.MEASURE_TIME)
            {
                sum[i] += Timer.NowUnixTime() - start[i];
            }
        }

        public void Print()
        {
            if (Runner.MEASURE_TIME && sum.Count > 0)
            {
                var sb = new StringBuilder();
                sb.Append("[");
                for (int i = 0; i < sum.Count; i++)
                {
                    sb.Append(sum[i]);
                    sb.Append(", ");
                }

                sb.Append("]");
                Console.Error.WriteLine(sb.ToString());
            }
        }
    }

    /// <summary>
    /// ユーティリティ（拡張メソッド）
    /// </summary>
    static class UtilExtension
    {
        public static string Show<T>(this T[,] ary)
        {
            var sb = new StringBuilder();
            sb.AppendLine("---------------------");
            int h = ary.GetLength(0);
            int w = ary.GetLength(1);
            for (int y = 0; y < h; y++)
            {
                for (int x = 0; x < w; x++)
                {
                    sb.Append(ary[y, x]);
                    if (x < w)
                        sb.Append(',');
                }

                if (y < h)
                    sb.Append('\n');
            }

            sb.AppendLine("---------------------");

            return sb.ToString();
        }
        
        public static string Show(this int[,,] ary, int INF)
        {
            var sb = new StringBuilder();
            sb.AppendLine("====================");
            for (int d = 0; d < ary.GetLength(2); d++)
            {
                int h = ary.GetLength(0);
                int w = ary.GetLength(1);
                for (int y = 0; y < h; y++)
                {
                    for (int x = 0; x < w; x++)
                    {
                        int value = ary[y, x, d];
                        if (value == INF)
                        {
                            sb.Append('.');
                        }
                        else
                        {
                            sb.Append(ary[y, x, d]);
                        }
                        if (x < w)
                            sb.Append(',');
                    }

                    if (y < h)
                        sb.Append('\n');
                }
                sb.AppendLine("---------------------");
            }

            sb.AppendLine("====================");

            return sb.ToString();
        }
    }

    #endregion
}

// CONTENT OFF -----
// CONTENT ON -----
namespace Marathon.Problem
{
    // ReSharper disable once ClassNeverInstantiated.Global
    public class Program
    {
        public static void Main(string[] args)
        {
            var runner = new Runner();
            runner.Run(args);
        }
    }

    public class Runner
    {
        public static string Name = "Initial";
        public static bool DEBUG = false;
        public static bool DEBUG_HEAVY = false;
        public static bool MEASURE_TIME = false;

        public Timer timer = new Timer();
        public TimerStat timerStat = new TimerStat();
        public long TL = 1800;

        public Random rnd;
        private TextReader reader;
        private TextWriter writer;
        public static Logger logger;

        // ユーティリティ
        public char[] DChars = new char[] {'D', 'R', 'U', 'L'};
        public int[] DX = new int[] {0, 1, 0, -1};
        public int[] DY = new int[] {1, 0, -1, 0};

        // 入力パラメータ
        public static int D;
        public static int K = 26;
        public static int[] C;
        public static int[,] S;

        // immutableな状態        
        public char[,] MAP;

        // mutableな状態
        public long bestScore;
        public int[] bestCommand;
        int counter;
        int counterUpdate;

        // パラメータ
        public int Seed;
        public Annealer annealer;

        public void Run(string[] args)
        {
            timer.Start();
#if LOCAL
            Directory.SetCurrentDirectory(
                Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));
            Directory.CreateDirectory("result");
            string inFileDir = "input";
            string outFileDir = "result";
            string inFileName = "example_02_in.txt";
            string outFileName = "example_02_out_my.txt";
            string inFilePath = Path.Combine(inFileDir, inFileName);
            string outFilePath = Path.Combine(outFileDir, outFileName);
            string inFileCopyPath = Path.Combine(outFileDir, inFileName);
            reader = new StreamReader(inFilePath);
            writer = new StreamWriter(outFilePath);
            File.Copy(inFilePath, inFileCopyPath, overwrite: true);
            TL = 1800;
            DEBUG = true;
#else
            reader = Console.In;
            writer = Console.Out;
#endif
            // 入力データの処理
            {
                {
                    D = int.Parse(reader.ReadLine());
                }
                {
                    C = reader.ReadLine().Split(' ').Select(int.Parse).ToArray();
                }
                {
                    S = new int[D, K];
                    for (int i = 0; i < D; i++)
                    {
                        var values = reader.ReadLine().Split(' ').Select(int.Parse).ToArray();
                        for (int k = 0; k < K; k++)
                        {
                            S[i, k] = values[k];
                        }
                    }
                }
            }

            // 初期化
            int seed = 71;
            rnd = new Random(seed);

            double initT = 2000.0;
            double finT = 600.0;
            annealer = new Annealer(initT, finT);

            // 計算の実行
            logger = new Logger(DEBUG);
            Solve();
            // logger.Info($"score: {calcScore(Order)}");

            // 出力
            WriteAnswer();

            logger.Close();
            writer.Close();

            timerStat.Print();
        }

        int ArgMax(int d)
        {
            int max = -1;
            int index = -1;
            for (int k = 0; k < K; k++)
            {
                int v = S[d, k];
                if (v > max)
                {
                    max = v;
                    index = k;
                }
            }

            return index;
        }

        void Solve()
        {
            var command = new int[D];
            for (int d = 0; d < D; d++)
            {
                command[d] = rnd.Next(K); // d % 26;
            }

            State state = new State(command);

            // 探索
            while (!(timer.Elapsed > TL))
            {
                // 焼きなまし
                long initialTime = timer.Elapsed;
                counter = 0;

                for (;;)
                {
                    counter++;

                    // 256ターンごとに処理
                    if ((counter & 0xFF) == 0)
                    {
                        long elapsed = timer.Elapsed;
                        if (elapsed > TL)
                        {
                            logger.Info("turn:" + counter + " bestScore:" + bestScore);
                            break;
                        }

                        if ((counter & 0xFF) == 0)
                        {
                            double anneal_t = 1.0 * (elapsed - initialTime) / (TL - initialTime);
                            annealer.SetTemperature(anneal_t);
                            logger.Info("Cooler:" + annealer.Temperature);
                        }
                    }

                    long newScore;
                    double prob = 0.5;
                    int flg = 0, p1_r1 = 0, p1_r2 = 0, p2_d1 = 0, p2_v1 = 0;
                    if (rnd.NextDouble() < prob)
                    {
                        flg = 1;
                        // 2点swap
                        while (true)
                        {
                            p1_r1 = rnd.Next(D);
                            p1_r2 = p1_r1 + 1 + rnd.Next(16);

                            // ReSharper disable once ReplaceWithSingleAssignment.True
                            bool valid = true;
                            if (p1_r2 >= D || state.Command[p1_r1] == state.Command[p1_r2]) 
                                valid = false;
                            if (valid)
                                break;
                        }

                        newScore = state.CalculationSwap(p1_r1, p1_r2);
                        // logger.Info($"score: {score} -> {newScore}");
                    }
                    else
                    {
                        // 1点更新
                        flg = 2;
                        while (true)
                        {
                            p2_d1 = rnd.Next(D);
                            p2_v1 = rnd.Next(K);
                            newScore = state.CalculationChange(p2_d1, p2_v1);
                        
                            // ReSharper disable once ReplaceWithSingleAssignment.True
                            bool valid = true;
                            if (state.Command[p2_d1] == p2_v1)
                                valid = false;
                            if (valid)
                                break;
                        }

                        // logger.Info($"score: {score} -> {newScore}");
                    }

                    // Timer1
                    if (annealer.Accept(state.Score, newScore))
                    {
                        // 変更が受理された場合
                        counterUpdate++;

                        if (flg == 1)
                        {
                            state.UpdateSwap(p1_r1, p1_r2);
                        }

                        if (flg == 2)
                        {
                            state.UpdateChange(p2_d1, p2_v1);
                        }

                        // logger.Debug($"accepted score: {score} turn:{turn} flg:{flg} time:{timer.Elapsed}");

                        // ベスト点数を超えている場合はその状態を保存
                        // TODO: 序盤の更新が多い場合は後半のみにするなど
                        if (bestCommand == null || (state.Score > bestScore))
                        {
                            bestScore = state.Score;
                            bestCommand = state.Command.ToArray();
                            logger.Info("score:" + bestScore + " at turn:" + counter);
                        }
                    }
                }
            }
        }

        void WriteAnswer()
        {
            logger.Fatal(
                $"final score: {bestScore}[{bestScore + 1000000}] time:{timer.Elapsed} counter:{counter} update:{counterUpdate}");
            var answer = bestCommand;
            for (int i = 0; i < answer.Length; i++)
            {
                // 1-indexedに直す
                writer.WriteLine(answer[i] + 1);
            }
        }
    }

    public class State
    {
        // 計算の高速化処理を含む
        public int[] Command;
        public long Score;
        public static int D;
        public static int K;
        public static int[] C;
        public static int[,] S;

        public int[,] LastContest; // 前のコンテストの日、初期値は-1 -- 常に-1日目に開催されると考えて良い
        public int[,] NextContest; // 次のコンテストの日、初期値はD -- 常にD日目に開催されると考えて良い

        public State(int[] command)
        {
            D = Runner.D;
            K = Runner.K;
            C = Runner.C;
            S = Runner.S;
            this.Command = command;
            InitialCalc();
        }

        public void InitialCalc()
        {
            long score = 0;
            for (int k = 0; k < K; k++)
            {
                long scoreK = 0;
                int last = 0;
                for (int d = 0; d < D; d++)
                {
                    if (k == Command[d])
                    {
                        scoreK += S[d, k];
                        last = d + 1;
                    }

                    scoreK -= (d + 1 - last) * C[k];
                }

                score += scoreK;
            }

            Score = score;

            // 初期化
            LastContest = new int[D, K];
            NextContest = new int[D, K];
            for (int k = 0; k < K; k++)
            {
                int last = -1;
                for (int d = 0; d < D; d++)
                {
                    LastContest[d, k] = last;
                    if (Command[d] == k)
                    {
                        last = d;
                    }
                }

                int next = D;
                for (int d = D - 1; d >= 0; d--)
                {
                    NextContest[d, k] = next;
                    if (Command[d] == k)
                    {
                        next = d;
                    }
                }
            }
        }

        public static long ScoreCalcRaw(int[] command)
        {
            // 素直な計算を行う
            long[] scoreContests = new long[K];
            for (int k = 0; k < K; k++)
            {
                long scoreK = 0;
                int last = 0;
                for (int d = 0; d < D; d++)
                {
                    if (k == command[d])
                    {
                        scoreK += S[d, k];
                        last = d + 1;
                    }

                    scoreK -= (d + 1 - last) * C[k];
                }

                scoreContests[k] = scoreK;
            }

            return scoreContests.Sum();
        }

        // ========================
        private long RemoveScore(int d, int k)
        {
            long diff = 0;
            diff -= S[d, k];
            int db1 = (d - 1) - LastContest[d, k];
            int db2 = NextContest[d, k] - (d + 1);
            int da1 = NextContest[d, k] - LastContest[d, k] - 1;
            int sb = db1 * (db1 + 1) / 2 + db2 * (db2 + 1) / 2;
            int sa = da1 * (da1 + 1) / 2;
            diff -= (-C[k] * sb);
            diff += (-C[k] * sa);
            return diff;
        }

        private long AddScore(int d, int k)
        {
            long diff = 0;
            diff += S[d, k];
            int db1 = NextContest[d, k] - LastContest[d, k] - 1;
            int da1 = (d - 1) - LastContest[d, k];
            int da2 = NextContest[d, k] - (d + 1);
            int sb = db1 * (db1 + 1) / 2;
            int sa = da1 * (da1 + 1) / 2 + da2 * (da2 + 1) / 2;
            diff -= (-C[k] * sb);
            diff += (-C[k] * sa);
            return diff;
        }

        private long SwapScore(int k, int db, int da)
        {
            // 重なるように動かすことはないとする
            Debug.Assert(da != db);
            Debug.Assert(NextContest[db, k] != da);
            Debug.Assert(LastContest[db, k] != da);

            // db -> da に動かす場合
            int next = NextContest[db, k];
            int last = LastContest[db, k];
            bool jump = (da > db && da > next) || (da < db && da < last);

            if (jump)
            {
                long diff = 0;
                diff += RemoveScore(db, k);
                diff += AddScore(da, k);
                return diff;
            }
            else
            {
                long diff = 0;
                diff -= S[db, k];
                diff += S[da, k];
                int db1 = (db - 1) - last;
                int db2 = next - (db + 1);
                int da1 = (da - 1) - last;
                int da2 = next - (da + 1);
                int sb = db1 * (db1 + 1) / 2 + db2 * (db2 + 1) / 2;
                int sa = da1 * (da1 + 1) / 2 + da2 * (da2 + 1) / 2;
                diff -= (-C[k] * sb);
                diff += (-C[k] * sa);
                return diff;
            }
        }

        private void RemoveUpdate(int dc, int k)
        {
            // Commandの処理は省略
            Score += RemoveScore(dc, k);

            // 更新
            {
                int d = dc - 1;
                while (d >= 0 && NextContest[d, k] == dc)
                {
                    NextContest[d, k] = NextContest[dc, k];
                    d--;
                }
            }

            {
                int d = dc + 1;
                while (d < D && LastContest[d, k] == dc)
                {
                    LastContest[d, k] = LastContest[dc, k];
                    d++;
                }
            }
        }

        private void AddUpdate(int dc, int k)
        {
            Command[dc] = k;
            Score += AddScore(dc, k);

            // 更新
            {
                int d = dc - 1;
                while (d >= 0 && d >= LastContest[dc, k])
                {
                    NextContest[d, k] = dc;
                    d--;
                }
            }

            {
                int d = dc + 1;
                while (d < D && d <= NextContest[dc, k])
                {
                    LastContest[d, k] = dc;
                    d++;
                }
            }
        }

        private void SwapUpdate(int k, int db, int da)
        {
            // 更新
            int next = NextContest[db, k];
            int last = LastContest[db, k];
            bool jump = (da > db && da > next) || (da < db && da < last);

            if (jump)
            {
                RemoveUpdate(db, k);
                AddUpdate(da, k);
            }
            else
            {
                Command[da] = k;
                Score += SwapScore(k, db, da);
                for (int d = last; d <= next; d++)
                {
                    if (d < 0 || d >= D) continue;
                    if (d != next)
                    {
                        if (d < da)
                            NextContest[d, k] = da;
                        else
                            NextContest[d, k] = next;
                    }

                    if (d != last)
                    {
                        if (d > da)
                            LastContest[d, k] = da;
                        else
                            LastContest[d, k] = last;
                    }
                }
            }
        }

        // ===========================-
        
        public long CalculationChange(int d, int k)
        {
            // d: kb -> k
            // kb == kであればそのまま
            int kb = Command[d];
            if (kb == k)
                return Score;

            // 差分計算
            long diff = 0;
            diff += RemoveScore(d, kb);
            diff += AddScore(d, k);

            if (Runner.DEBUG_HEAVY)
            {
                int[] command = Command.ToArray();
                command[d] = k;
                long scoreX = ScoreCalcRaw(command);
                if (scoreX != Score + diff)
                    throw new Exception();
            }

            return Score + diff;
        }

        public void UpdateChange(int d, int k)
        {
            int kb = Command[d];
            RemoveUpdate(d, kb);
            AddUpdate(d, k);

            if (Runner.DEBUG_HEAVY)
            {
                Runner.logger.Info($"Update Change d:{d} k:{k}");
                if (ScoreCalcRaw(Command) != Score)
                    throw new Exception();
            }
        }

        public long CalculationSwap(int d1, int d2)
        {
            // d1: k1 -> k2
            // d2: k2 -> k1
            // k1 == k2であればそのまま

            int k1 = Command[d1];
            int k2 = Command[d2];
            if (k1 == k2)
                return Score;

            // 差分計算
            long diff = 0;
            diff += SwapScore(k1, d1, d2);
            diff += SwapScore(k2, d2, d1);

            if (Runner.DEBUG_HEAVY)
            {
                Runner.logger.Info($"Update Swap d1:{d1} d2:{d2} k1:{k1} k2:{k2}");
                int[] command = Command.ToArray();
                command[d1] = k2;
                command[d2] = k1;
                long scoreX = ScoreCalcRaw(command);
                if (scoreX != Score + diff)
                    throw new Exception();
            }

            return Score + diff;
        }

        public void UpdateSwap(int d1, int d2)
        {
            int k1 = Command[d1];
            int k2 = Command[d2];
            SwapUpdate(k1, d1, d2);
            SwapUpdate(k2, d2, d1);
            if (Runner.DEBUG_HEAVY)
            {
                if (ScoreCalcRaw(Command) != Score)
                    throw new Exception();
            }
        }
    }

    public class Annealer
    {
        public double InitialT;
        public double FinalT;
        public double Temperature;
        private Random rand = new Random(71);

        public Annealer(double initialT, double finalT)
        {
            InitialT = initialT;
            FinalT = finalT;
        }

        public void SetTemperature(double t)
        {
            double tp0 = InitialT;
            double tp1 = FinalT;
            // 線形とした
            // TODO: 指数関数型への変更
            // Temperature = it * (1 - t) + ft * t;

            Temperature = Math.Pow(tp0, 1.0 - t) * Math.Pow(tp1, t);
        }

        public bool Accept(double prev, double cur)
        {
            if (cur >= prev) return true;
            double loss = cur - prev;
            double prob = Math.Exp(loss / Temperature);
            return rand.NextDouble() < prob;
        }
    }
}


// CONTENT OFF -----
// CONTENT ON -----

namespace Marathon.Problem
{
    #region Structure

    public struct Pos
    {
        public int y;
        public int x;

        public Pos(int y, int x)
        {
            this.y = y;
            this.x = x;
        }
    }

    public class PriorityQueue<T>
    {
        private Comparison<T> _comparison;
        private int _type = 0;

        private T[] _heap;
        private int _sz = 0;

        private int _count = 0;

        /// <summary>
        /// Priority Queue with custom comparer
        /// </summary>
        public PriorityQueue(Comparison<T> comparison)
        {
            _heap = new T[128];
            _comparison = comparison;
        }

        private int Compare(T x, T y)
        {
            return _comparison(x, y);
        }

        public void Push(T x)
        {
            _count++;
            if (_count > _heap.Length)
            {
                var newheap = new T[_heap.Length * 2];
                for (int n = 0; n < _heap.Length; n++) newheap[n] = _heap[n];
                _heap = newheap;
            }

            //node number
            var i = _sz++;

            while (i > 0)
            {
                //parent node number
                var p = (i - 1) / 2;

                if (Compare(_heap[p], x) <= 0) break;

                _heap[i] = _heap[p];
                i = p;
            }

            _heap[i] = x;
        }

        public T Pop()
        {
            _count--;

            T ret = _heap[0];
            T x = _heap[--_sz];

            int i = 0;
            while (i * 2 + 1 < _sz)
            {
                //children
                int a = i * 2 + 1;
                int b = i * 2 + 2;

                if (b < _sz && Compare(_heap[b], _heap[a]) < 0) a = b;

                if (Compare(_heap[a], x) >= 0) break;

                _heap[i] = _heap[a];
                i = a;
            }

            _heap[i] = x;

            return ret;
        }

        public int Count()
        {
            return _count;
        }

        public T Peek()
        {
            return _heap[0];
        }

        public bool Contains(T x)
        {
            for (int i = 0; i < _sz; i++)
                if (x.Equals(_heap[i]))
                    return true;
            return false;
        }

        public void Clear()
        {
            while (this.Count() > 0) this.Pop();
        }

        public IEnumerator<T> GetEnumerator()
        {
            var ret = new List<T>();

            while (this.Count() > 0)
            {
                ret.Add(this.Pop());
            }

            foreach (var r in ret)
            {
                this.Push(r);
                yield return r;
            }
        }

        public T[] ToArray()
        {
            T[] array = new T[_sz];
            int i = 0;

            foreach (var r in this)
            {
                array[i++] = r;
            }

            return array;
        }
    }

    #endregion
}

// CONTENT OFF -----


Measured memory_bytes: 25760