Work

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

문제

There are NN men and MM different working assignments for them. You are given a matrix AA in which A_i,j=1A\_{i,j} = 1 if ii-th worker is qualified to complete jj-th job, and A_i,j=0A\_{i,j} = 0 otherwise. A worker can be assigned to a job only if he is qualified to complete that job.

Your goal is to assign workers to jobs in such a way that the distribution of the amounts of jobs done by workers is as close as possible to uniform (in Euclidean metric). This means that the NN-dimensional vector in which ii-th element is the amount of jobs completed by ii-th worker must be as close as possible to the NN-dimensional vector in which each element is equal to the real number M/NM / N.

An additional requirement is that each job which can be completed at all must be assigned to exactly one worker.

입력

The first line of input contains two integers NN and MM (1N,M3001 \le N, M \le 300). It is followed by NN lines each containing MM characters. Each of these characters is either '0' or '1'. These lines represent the matrix AA.

출력

Print NN lines. On ii-th line, first, print k_ik\_i, the amount of jobs assigned to ii-th worker. After that, print the numbers of those jobs. If there are several different ways to assign jobs and get an optimal distribution, print any one of them.

힌트

The Euclidean distance between two vectors (u_1,u_2,,u_N)(u\_1, u\_2, \ldots, u\_N) and (v_1,v_2,,v_N)(v\_1, v\_2, \ldots, v\_N) is the real number (v_1u_1)2+(v_2u_2)2++(v_Nu_N)2.\sqrt{(v\_1 - u\_1)^2 + (v\_2 - u\_2)^2 + \ldots + (v\_N - u\_N)^2}\text{.}