program scoring
    implicit none
    integer(8)::D,C(26),last(26,365),last_sim(26,365),i,j,k,l,vmax,tbest,dadd,i_calc,vbest,add_best,score
    integer(8),allocatable::S(:,:),T(:),Tans(:),V(:)

    !入力
    read*,D,C
    allocate(S(26,D))
    allocate(T(D))
    allocate(Tans(D))
    allocate(V(D))
    read*,S
    T=0
    V=0
    last=0
    last_sim=0

    !貪欲法
    do dadd=0,0
        T=0
        V=0
        last=0
        last_sim=0
        !今日の日付+dadd日目のパラメータを使用して満足度を計算する
        do i=1,D
            i_calc=min(i+dadd,D)
            do j=1,26
                !得点の初期化
                if(i==1)V(i)=0
                if(i>1)V(i)=V(i-1)

                !lastの初期化
                if(i==1)last(:,i)=0
                if(i>1)last(:,i)=last(:,i-1)

                last(j,i)=i
                V(i)=V(i)+S(j,i)
                
                do k=1,26
                    do l=i,i_calc
                        V(i)=V(i)-C(k)*(l-last(k,i))
                    end do
                end do

                if(j==1)then
                    vmax=V(i)
                    tbest=j
                else if(V(i)>=vmax)then
                    vmax=V(i)
                    tbest=j
                end if
            end do
            if(i==1)last(:,i)=0
            if(i>1)last(:,i)=last(:,i-1)
            T(i)=tbest
            last(tbest,i)=i
        end do
        !print'(i0)',V(D)

        !得点の再計算
        score=0
        do i=1,D
            score=score+S(T(i),i)
            do j=1,26
                score=score-C(j)*(i-last(j,i))
            end do
        end do

        !print'(i0)',score
        if(dadd==0.or.score>vbest)then
            add_best=dadd
            vbest=score
            Tans(:)=T(:)
        end if
    end do
    !print'(i0)',vbest
    !print'(i0)',add_best
    !print'(A)',""

    do i=1,D
        print'(i0)',Tans(i)
    end do
end program scoring