Loteria

Decide whether K target parities can be chosen so that no non-empty subset of the given rows has column sums matching all of them.

Medium5MathBit manipulationBrute forceImplementationNo attempts yetTime limit1sMemory limit512 MB

Problem

The BWS Loteria draw is held once a year. NN people enter it, and each of them picks KK numbers. Write Bi,jB_{i,j} for the jj-th number picked by the ii-th person. The organizers then pick KK positive integers of their own, called W1,W2,,WKW_1, W_2, \dots, W_K.

The winners are decided like this.

  • A non-empty subset of the NN entrants is drawn at random.
  • Add up the first number picked by every person in that subset and call the total S1S_1. That is, S1S_1 is the sum of Bi,1B_{i,1} over the indices ii in the subset. Compute S2,,SKS_2, \dots, S_K the same way.
  • For every jj, check whether WjW_j and SjS_j have the same parity, meaning both are even or both are odd.
  • If the parities agree for every jj, that set of people wins.

The organizers want to know whether they can pick W1,W2,,WKW_1, W_2, \dots, W_K so that no subset of the entrants wins.

Input

The first line contains the number of entrants NN and the count of numbers each person picks, KK. (1N1041 \le N \le 10^4, 3K503 \le K \le 50)

Each of the next NN lines contains the KK numbers picked by one person. Every picked number is an integer between 11 and 5050, inclusive.

Output

Print S if the organizers can pick W1,W2,,WKW_1, W_2, \dots, W_K so that no subset wins, and N otherwise.