405593: GYM102006 F Pretests

Memory Limit:256 MB Time Limit:8 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

F. Preteststime limit per test8 secondsmemory limit per test256 megabytesinputtests.inoutputstandard output

In a contest like the one you are participating in currently, a verdict of Accepted means that your solution was run on all test cases and produced the correct output for them all. However, some popular websites that hold online rounds prefer to use a pretest system. Your solution would be run on a subset of the test cases when you submit it, otherwise known as pretests.

For a problem with t pretests, solutions are judged on them in order, one by one, until it fails to produce a correct output. So, if a solution fails on the kth test, it will request k test runs, and if it never fails, it will request t test runs.

To prevent the system from lagging, it would be preferable if the total number of test runs for all submissions was minimized.

You are given the verdicts of n submissions on each of the t pretest cases.

Print the minimum total number of runs needed if the pretests were ordered optimally. If there is more than one order that minimizes the answer, print the lexographically smallest one.

Input

The first line of input contains a single integer P, the number of problems you are ordering the pretests for.

The first line for each of the P problems contains two space-separated integers t and n (1 ≤ t ≤ 20) (1 ≤ n ≤ 2 × 105), the number of pretests for this problem and the number of submissions, respectively.

Each of the following n lines contains t characters representing the verdicts of this submission on each of the pretests, the ith character is '1' if this submission passes the ith pretest, or '0' if it fails.

Output

For each of the P problems, output two lines. On the first line, print the minimum total number of test runs needed if the pretests were ordered optimally.

On the second line, print a permutation of the numbers from 1 to t, representing the lexographically smallest order of the pretests that produces the minimum answer.

ExampleInput
1
4 3
1100
0101
0011
Output
4
1 3 2 4
Note

A permutation a is lexicographically smaller than permutation b if there exists an index i such than ai < bi and aj = bj for all (1 ≤ j < i).

加入题单

算法标签: