Andy is on his school's team for the UBC Physics Olympics. During the competition, however, he remembered that he only had a 60% in Physics class and didn't know how to solve any of the problems. Since he has other teammates, he is just going to AFK and let them do all the work for him.
There are problems in the contest. Andy realized that some of his teammates would deceive the rest of his team about the solution to each problem. Andy calculated how much each teammate would deceive the team for each problem, , where is the student number, and is the problem number. For each teammate, he can strategically annoy them on one problem to set their deception value to (note that he can choose not to annoy any teammate). For each problem, Andy can only annoy one teammate.
The deception value for a problem is the XOR sum of all the deception values of all his teammates. The total deception value for the contest is the sum of all the individual values of each problem.
Andy wishes to know the minimum overall deception value possible, so determine it for him.
Constraints
For all test cases:
Input Specification
The first line contains two integers and , the number of tasks and teammates.
The next lines each contain integers, with each row representing a student and each number in the row representing the deception value of that student in that problem.
Output Specification
Output the minimum deception value of the contest.
Sample Input
5 3
3 3 0 3 5
5 5 4 3 5
1 5 4 2 1
Sample Output
3
Sample Explanation
A way to minimize the deception value is to annoy teammate on the first problem, teammate on the second problem, and teammate on the fourth problem.
This results in a deception level of for the problems, meaning the total deception value is .
Comments