On a switchboard there are lamps arranged in an array. In the beginning all lamps are off. At each step one can switch three consecutive lamps in one row or in one column, changing the state of each lamp to the opposite. For which pairs of positive integers is it possible to achieve the situation, where all the lamps are switched on?
Solution
If (or ) is a multiple of , then we can divide all lamps in each column (or row) into groups of and switch the lamps on by the groups.
If neither nor is a multiple of , then color all lamps by diagonals with three colors (Fig. 10). Then each switching changes the state of exactly one lamp of each color, therefore each switching changes the parity of the number of lamps switched on for each color. Since in the beginning all lamps are off, the parity of the lamps switched on for each color always stays the same.
Let and , where and are nonnegative integers and and are either or . In regions of sizes , and the numbers of lamps of each color are equal and hence their parities are equal, but in the remaining region there is either lamp (Fig. 11), lamps of different colors (Fig. 12 and 13), or lamps, of which are of one color and two others of the two other colors (Fig. 14), hence the parities of the numbers of lamps of each color are not equal. Consequently, it is not possible to switch on all lamps.

Fig. 10

Fig. 11

Fig. 12

Fig. 13

Fig. 14