You are given the last rows of an boolean matrix . Your task is to determine boolean values for the first row such that is maximized (see notes). You only need to output the value of .
The first line contains integer .
Lines through contain numbers each: line containing the numbers (either or ) in the row of .
Output non-negative integer on the single line.
is a boolean matrix iff ,
The determinant of an matrix , denoted , is a scalar that is defined inductively as:
Where is the matrix obtained from by deleting the row and column containing
= The remainder of division of by B.