Jimin has an N by M rectangular table with one lamp in each cell. Each lamp is either on or off. There is one switch under each column. Pressing a switch flips the state of every lamp in that column: lamps that were on turn off, and lamps that were off turn on.
A row is called lit if every lamp in that row is on. Jimin will press switches exactly K times. The same switch may be pressed more than once.
After exactly K switch presses, Jimin wants to maximize the number of lit rows. Given the initial lamp states and K, find that maximum possible number.