International Mathematical Olympiad 2016 Problem 2
Find all positive integers for which each cell of an table can be filled with one of the letters , and in such a way that:
- in each row and each column, one third of the entries are , one third are and one third are ; and
- in any diagonal, if the number of entries on the diagonal is a multiple of three, then one third of the entries are , one third are and one third are .
Note: The rows and columns of an table are each labelled 1 to in a natural order. Thus each cell corresponds to a pair of positive integers with . For , the table has diagonals of two types. A diagonal of the first type consists of all cells for which is a constant, and a diagonal of the second type consists of all cells for which is a constant.