#t419. 花店橱窗布置

花店橱窗布置

Flower Shop Window Arrangement

Problem Description

A flower shop has FF bouquets of flowers, each of a different variety. There are at least as many vases, arranged in a row in order. The positions of the vases are fixed, numbered from left to right as 1∼V1\sim V, where VV is the number of vases.

The bouquets can be moved, and each bouquet is identified by an integer 1∼F1\sim F. All bouquets must keep their identification order when placed into vases. For example, suppose the azalea has identification 11, the begonia 22, and the carnation 33; then the azalea must be placed in a vase to the left of the begonia, and the begonia must be placed to the left of the carnation. Each vase can hold at most one bouquet.

The shape and color of each vase also differ, so placing different bouquets in different vases produces different aesthetic effects, represented by an aesthetic value (an integer ai,ja_{i,j}); the aesthetic value of an empty vase is 00. In the example above, the aesthetic values of different combinations of vases and bouquets can be represented by the following table:

Vase 1 Vase 2 Vase 3 Vase 4 Vase 5
Azalea 77 2323 −5-5 −24-24 1616
Begonia 55 2121 −4-4 1010 2323
Carnation −21-21 55 −20-20 2020

According to the table, an azalea placed in vase 22 looks very nice, but placed in vase 44 looks terrible.

To achieve the best aesthetic effect, the bouquets must be placed keeping their order, maximizing the total aesthetic value. If there is more than one arrangement achieving the maximum aesthetic value, output any one of them.

Input Format

The first line of the input file contains two integers FF and VV, the number of bouquets and the number of vases, respectively.

Next is the matrix ai,ja_{i,j}, with FF rows, each containing VV integers; ai,ja_{i,j} is the aesthetic value of placing bouquet ii in vase jj.

Output Format

The first line of the output file is an integer: the maximum aesthetic value. The next line contains FF integers: the vase number where each bouquet is placed.

Sample Input 1

3 5
7 23 -5 -24 16
5 21 -4 10 23
-21 5 -4 -20 20

Sample Output 1

53
2 4 5

Constraints

For 100%100\% of the data, 1≤F≤V≤1001\le F\le V\le 100.