QOJ.ac

QOJ

حد الوقت: 1.0 s حد الذاكرة: 1024 MB مجموع النقاط: 100 قابلة للهجوم ✓

#15242. The 9th Hebei Collegiate Programming Contest

الإحصائيات

oql and his teammates need to prepare problems for the Hebei Collegiate Programming Contest (hereinafter referred to as the Hebei Provincial Contest). A standard CCPC contest usually consists of 10 to 13 problems. This time, they have prepared $n$ problems and want to select a subset of them to be the official problems for the Hebei Provincial Contest.

Currently, oql has already obtained data on all participating teams in the Hebei Provincial Contest and has used magic to know whether each team can solve each problem. Assuming each team performs at their best in the Hebei Provincial Contest (and you can be sure they will perform at their best at this moment), all teams will solve exactly the problems they are capable of solving. Of course, if a team cannot solve a problem, they will not solve it.

As is well known, CCPC ranks teams based on the number of problems solved and the penalty time. Since this problem only concerns the number of problems solved, the penalty time can be ignored. oql has already obtained the rankings for the Hebei Provincial Contest, where the last-place teams for the gold, silver, and bronze medals are $r_{kg}, r_{ks}, r_{kb}$ respectively (with the champion being ranked 1st). To provide a better competition experience, oql wants to ensure that among the $n$ problems, if $10$ to $13$ problems are selected as official problems, the number of problems solved by the teams ranked $r_{kg}, r_{ks}, r_{kb}$ will be exactly $p_g, p_s, p_b$. If possible, oql would like you to tell him a valid selection scheme.

Input

The first line contains two integers $n, m$ ($10 \le n \le 18, 3 \le m \le 200$), representing the total number of prepared problems and the number of participating teams.

The next $m$ lines, each containing a string of length $n$ consisting of $a_{i,1}a_{i,2} \dots a_{i,n}$, represent the problem-solving status of the $i$-th team. If $a_{i,j} = 1$, it means the $i$-th team can solve the $j$-th problem; otherwise, $a_{i,j} = 0$.

The next line contains three integers $r_{kg}, r_{ks}, r_{kb}$ ($1 \le r_{kg} < r_{ks} < r_{kb} \le m$), representing the rankings of the last-place teams for the gold, silver, and bronze medals, respectively.

The last line contains three integers $p_g, p_s, p_b$ ($1 \le p_b \le p_s \le p_g \le \min(n, 13)$), representing the number of problems solved by the teams ranked $r_{kg}, r_{ks}, r_{kb}$ that oql desires.

Output

If no valid scheme exists, output -1 and no further output is needed.

Otherwise, the first line outputs an integer $k$, representing how many problems are chosen in a valid selection scheme.

The second line outputs $k$ integers, representing the indices of the chosen problems. The problem indices start from 1. Your output must contain $k$ distinct integers from $1$ to $n$.

If there are multiple valid schemes, output any one of them.

Examples

Input 1

13 3
1111111111111
1111111111110
11111110000
1 2 3
12 11 8

Output 1

12
1 2 3 4 5 6 7 8 10 11 12 13

Note

The first team solves all problems, so they must be in first place. The first-place team solves 12 problems, so the final valid scheme can only be 12 problems.

Considering the first place, any problem from 1 to 13 can be removed.

Considering the second place, any problem from 1 to 12 can be removed.

Considering the third place, any problem from 1 to 9 can be removed.

In summary, a valid scheme is to remove only problem 9, keeping all other problems.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.