Problem
Let and be positive integers. Consider an square array consisting of lamps that can be in two states - on or off. At the beginning all lamps are turned off. A move consists of choosing a row or a column of the array and changing the state of consecutive lamps in the chosen row or column, i.e. turning on the lamps that are turned off and vice versa. Determine the necessary and sufficient condition for which it can be achieved that after a finite number of moves all lamps are turned on. (Tonći Kokan)