The Smallest Expedition Crew
Dr. Varga is organizing an expedition and has narrowed the roster down to n volunteers.
The expedition requires s distinct named skills (things like rope rigging, cold-weather
medicine, radio repair, and so on — the exact names don't matter, only which volunteers
have which ones).
Each volunteer has already been assessed and has some subset of the s required skills
(possibly none, possibly all of them). Dr. Varga wants to send as few volunteers as
possible, while making sure that, between the volunteers who go, every one of the s
required skills is covered by at least one team member. A volunteer who goes along
contributes all of the skills they have, even ones nobody ends up needing twice.
Given the skill set of every volunteer, find the smallest possible expedition crew that
covers all s required skills, and report who should go.
It is guaranteed that the full group of n volunteers together covers all s skills, so
a valid crew always exists.
Input
The first line contains two integers n and s (1 ≤ n ≤ 60, 1 ≤ s ≤ 16) — the number of
volunteers and the number of required skills.
Each of the next n lines contains a string of exactly s characters, each 0 or 1.
The j-th character of the i-th string is 1 if volunteer i (1-indexed) has the
j-th required skill, and 0 otherwise.
Output
Print two lines.
On the first line, print k — the minimum number of volunteers needed so that their
combined skills cover all s required skills.
On the second line, print k distinct integers — the 1-indexed positions of the chosen
volunteers, in any order. The union of their skills must cover all s required skills,
and k must be as small as possible. If several crews of minimum size work, printing any
one of them is accepted.
Notes
In the first example, volunteer 1 alone already has both required skills, so a crew of size 1 suffices.
In the second example, no single volunteer covers all three skills, but volunteers 1 and 2 together do, and no volunteer covers all three alone, so the minimum crew size is 2.