Voting

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

The political situation in Berland has changed. With the opposing party candidate having won the election, the multi-level voting system has finally been canceled. Now the president of Berland is elected by a single total voting. But the conservative zealots are busy peddling the idea to the masses that the new voting is even more prone to tampering with the results than ever before. To refute these calumnies, the president requested to evaluate the costs of fixing voting results by bribing voters.

There is a total of NN voters and KK candidates. Each of the voters can either cast his voice for a single candidate or abstain from voting, for example, by not going to the election. Once all voters have voted (one way or another), the number of voices collected by each candidate is counted. The candidate who gets strictly the most voices wins. If there is no such candidate, the elections are deemed null and void.

You are asked to write a program based on the following statements. For each individual voter the candidate for whom he or she is going to vote is known. It is allowed to change the voter's preference to any other variant by spending a certain sum of money. The goal is for the necessary candidate to win the elections. Minimize the amount of money necessary to complete this task.

입력

The first line of the input file contains three integers: NN --- the count of voters in Berland, KK --- the count of candidates running for presidency, TT --- the index of candidate who needs the elections fixed in his favor (1N1001 \le N \le 100, 1K101 \le K \le 10, 1TK1 \le T \le K). Both all voters and all candidates are numbered in succession beginning from the number one.

This is followed by a costs matrix of NN lines and K+1K+1 columns. The element C_i,jC\_{i,j} of the matrix defines the amount of money to be spent in order to assure that the ii-th voter votes for the jj-th candidate (with 1iN1 \le i \le N, 1jK1 \le j \le K). The last element C_i,K+1C\_{i,K+1} in the line defines the amount of money to be spent in order to keep the voter from going to the elections.

It is guaranteed that all costs C_i,jC\_{i,j} are integers and fall within the range of 0C_i,j1090 \le C\_{i,j} \le 10^9. In addition, for each ii strictly one of the numbers C_i,1,C_i,2,,C_i,K+1C\_{i,1}, C\_{i,2}, \ldots, C\_{i,K+1} equals zero: the zero means that the given voter has been planning to vote in the corresponding way.

출력

The first line of the output file must contain a single integer --- the minimum required amount of money to be spent in order to change the voters' preferences.

The second line of the input file must contain NN integers. The ii-th of these numbers V_iV\_i means that the ii-th voter must vote for the V_iV\_i-th candidate(1V_iK+11 \le V\_i \le K+1). The special value V_i=K+1V\_i = K+1 means that the ii-th voter must skip the elections.

If there are several optimal solutions, print any of them.

힌트

The example suggests that the second voter's preference must be changed to skipping the elections (costing 11 unit of money), and that the fourth voter must be persuaded to vote for the desired candidate (costing 22 units). As the result, only the first voter is going to vote for the first candidate, with the fourth and fifth voters voting for the second candidate.