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

namespace AtCoder2.Heuristic
{
    class Node
    {
        public List<Node> NodeStack;
        /// <summary>積み終わったコンテストの数</summary>
        public int Day;
        public List<int> Contests;
        public int[] ContestPenalties = new int[26];
        public long Score;
        public int NextPenalty;                         // 総和は最大で3650
        public Node AddContest(int contestNo)
        {
            var node = new Node()
            {
                Day = Day + 1,
                Contests = new List<int>(Contests),
                NodeStack = new List<Node>(NodeStack),
            };
            node.Score = Score - NextPenalty + ContestPenalties[contestNo] + Introduction.ContestScore[Day][contestNo];
            node.NodeStack.Add(this);
            node.Contests.Add(contestNo);

            node.ContestPenalties[contestNo] = 0;
            node.NextPenalty = 0;
            for (var i = 0; i < 26; i++)
            {
                node.ContestPenalties[i] = (i == contestNo ? 0 : ContestPenalties[i]) + Introduction.ScoreMinus[i];
                node.NextPenalty += node.ContestPenalties[i];
            }

            return node;
        }
    }

    class Introduction
    {
        public static List<int> ScoreMinus = new List<int>();
        public static List<List<int>> ContestScore = new List<List<int>>();
        static System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();


        static Random Random = new Random(42);


        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());  // 365

            ScoreMinus = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            for (int i = 0; i < N; i++)
            {
                ContestScore.Add(Console.ReadLine().Split(' ').Select(int.Parse).ToList());
            }

            sw.Start();

            var startNode = new Node();
            for (int i = 0; i < 26; i++)
            {
                startNode.ContestPenalties[i] += ScoreMinus[i];
                startNode.NextPenalty += ScoreMinus[i];
            }
            /*
                        // B問題シミュレーション
                        var bNode = new Node() { NextPenalty = startNode.NextPenalty, Contests = new List<int>(), ContestPenalties = startNode.ContestPenalties.ToArray(), NodeStack = new List<Node>() };

                        for (int i = 0; i < N; i++)
                        {
                            int v = int.Parse(Console.ReadLine()) - 1;
                            bNode = bNode.AddContest(v);
                            Console.WriteLine(bNode.Score);
                        }
                        return;
            */

            Stack<Node> nodes = new Stack<Node>();

            var bestNode = new Node() { NextPenalty = startNode.NextPenalty, Contests = new List<int>(), ContestPenalties = startNode.ContestPenalties.ToArray(), NodeStack = new List<Node>() };
            while (bestNode.Day < N)
            {
                bestNode = bestNode.AddContest(Random.Next(26));
                nodes.Push(bestNode);
            }

            // game loop
            while (sw.ElapsedMilliseconds <= 1900)
            {
                int startDay = (int)(N * (sw.ElapsedMilliseconds / 1950.0));
                var node = bestNode.NodeStack[startDay];

                while (node.Day < N)
                {
                    node = node.AddContest(Random.Next(26));
                }

                if (node.Score > bestNode.Score)
                {
                    bestNode = node;
                    //Console.Error.WriteLine($"@ score:{node.Score}");
                }
            }


            for (int i = 0; i < N; i++)
            {
                Console.WriteLine(bestNode.Contests[i] + 1);
            }


        }
    }

}


Measured memory_bytes: 53212