program pleonexia
    implicit none
    integer D, day, wait, i, candidate, maxScore, tempScore
    integer, dimension(26) :: c, last
    integer, dimension(:, :), allocatable :: satisfy
    integer, dimension(:), allocatable :: typ

    read *, D
    read *, c
    last(:) = 0

    allocate(satisfy(26, D))
    allocate(typ(D))

    read *, satisfy

    ! typ(:) = 1
    ! print *, score(1, c, satisfy, D, typ)

    do day=1,D
        candidate = 1
        typ(day) = 1
        maxScore = score(1, c, satisfy, D, typ)
        do i=2,26
            typ(day) = i
            tempScore = score(day, c, satisfy, D, typ)
            if (tempScore > maxScore) then
                maxScore = tempScore
                candidate = i
            endif
        enddo
        typ(day) = candidate
    enddo

    do day=1,D
        print *, typ(day)        
    enddo

    contains
    integer function score(date, c, satisfy, D, typ)
    implicit none
    integer, intent(in) :: date, D
    integer, intent(in), dimension(26) :: c
    integer, intent(in), dimension(:, :) :: satisfy
    integer, intent(in), dimension(:) :: typ
    integer day, wait, result
    integer, dimension(26) :: last

    last(:) = 0
    
    result = 0
    do day=1,date
        last(typ(day)) = day
        wait = 0
        do i=1,26
            wait = wait + c(i)*(day - last(i))
        enddo
        result = result + satisfy(typ(day), day) - wait
    enddo
    score = result
end function score

end program pleonexia