program scoring
    implicit none
    integer(8)::D,C(26),last(26,365),last_sim(26),i,j,k,vmax,tbest
    integer(8),allocatable::S(:,:),T(:),V(:),Vorigin(:)
    !時間計測開始

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

    !貪欲法による初期解の生成
    do i=1,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
                V(i)=V(i)-C(k)*(i-last(k,i))
            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


    !答えの出力
    do i=1,D
        print'(i0)',T(i)
    end do
end program scoring

subroutine rnd_int(rnd,rnd_max)
    integer(8),intent(in)::rnd_max
    integer(8),intent(out)::rnd
    real::rnd_real
    call random_number(rnd_real)
    rnd=mod(int(rnd_real*100000000),rnd_max)+1
    return
end subroutine rnd_int