402196: GYM100694 F The Berland Championship
Description
Every year BerSU (Berland State University) holds the programming contest «The Berland Championship». This year Andrey, the student of BSAU (Berland State Alternative University), helped to prepare the problems. There were m problems prepared in total.
Andrey is proud of his university very much so he wants the BSAU team to win. Of course, he isn't allowed to share the problems with BSAU teams, but he can give advice how to form the teams.
n BSAU students want to take part in the competition. For each student, Andrey knows what problems he can solve, and also what is his productivity — the maximum number of problems he can solve during the contest. Every team must consist of three students. Andrey believes that BSAU students will act optimally at the contest, that is, everyone will solve the maximal number of problems he can. However, no student will solve more problems than his productivity, and no team will solve problems that aren't solvable by its students.
Help Andrey to form exactly one team of three students so it could solve the maximal number of problems comparing to all other possible BSAU teams.
InputThe first line contains two integers n, m (3 ≤ n ≤ 50, 1 ≤ m ≤ 1000) — the number of BSAU students and the number of problems.
The second line contains n integers pi (0 ≤ pi ≤ m) — the productivities of the students.
Each of the next n lines contains a string of uppercase and lowercase Latin letters namei (|namei| ≤ 10) — the name of the i-th student. All names are pairwise distinct.
Then the binary matrix a of size n × m follows. Its rows correspond to students, and columns — to problems. If ai, j is 1, i-th student can solve j-th problem, otherwise he can't.
OutputIn the first line output a single integer s — the maximal number of problems the team formed by Andrey can solve.
In the second line output the names of the students in this team. The names can be written in any order.
If there are several optimal solutions, output any of them.
ExamplesInput5 5Output
3 2 2 3 1
Slava
Andrew
Egor
Denis
Sergey
11011
10100
00001
00100
10000
5Input
Slava Andrew Egor
4 6Output
1 2 1 2
Denis
Andrew
Egor
Slava
100011
111100
000101
000111
5
Denis Andrew Slava