Under construction

Still being built. Things may change

Loteria

Time limit1sMemory limit512 MB

Summary
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.
Level

Medium5 of 10

Topics
Math, Bit manipulation, Brute force, Implementation
Solved
No attempts yet

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. (1≤N≤1041 \le N \le 10^4, 3≤K≤503 \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.

Examples3

  1. Example 1

    Input
    2 3
    1 2 3
    5 6 7
    
    Expected output
    S
    
  2. Example 2

    Input
    3 3
    3 2 1
    6 5 4
    4 4 4
    
    Expected output
    S
    
  3. Example 3

    Input
    4 3
    9 4 7
    4 4 4
    2 7 2
    2 2 1
    
    Expected output
    N