An $n\times n$ matrix $A$ that contains each of $1,2,\cdots, n$ exactly $n$ times and $A^2\equiv 0\pmod n$ Construct a matrix $A \in \{1,\,2, ...,\,n\}^{n \times n}$ such that
(1) Each integer between $[1, n]$ occurs in $A$ exactly $n$ times,
(2) For all integers $i,\,j \in [1, n]$, $(A^2)_{ij} \equiv 0\,(\text{mod}\,n)$,
or report such $A$ does not exist. Here $A^2 := A*A$ is matrix multiplication.
This problem is not proposed by me. It is proposed on the Codeforces forum: https://codeforces.com/blog/entry/111297. For odd $n$ we can construct $A$ easily: Just fill every row of $A$ with $1,\,2, ...\,n$. But what about even $n$?

We have the following interesting family of examples. If $n$ is divisible by $4$, then take $B$ to be the matrix whose columns are
$$
c_1 = \left(1,3,\dots,\frac n2 - 1, 0\dots,0,\frac n2 + 1,\frac n2 + 3,\dots, n-1\right),\\
c_2 = \left(0,0,\dots,0, 1,\dots,1,0,0,\dots, 0\right),
$$
and take $C$ to be the matrix whose rows are
$$
r_1 = (1,\dots,1), \quad r_2 = (n,\dots,4,2,2,4,\dots,n)
$$
Then the matrix $A = BC$ contains each element of $\{1,\dots,n\}$ $n$ times and satisfies $A^2 = 0$.  For $n = 4,8,$ this produces the examples
$$
\left[\begin{matrix}1 & 1 & 1 & 1\\4 & 2 & 2 & 4\\4 & 2 & 2 & 4\\3 & 3 & 3 & 3\end{matrix}\right], \quad \left[\begin{matrix}1 & 1 & 1 & 1 & 1 & 1 & 1 & 1\\3 & 3 & 3 & 3 & 3 & 3 & 3 & 3\\8 & 6 & 4 & 2 & 2 & 4 & 6 & 8\\8 & 6 & 4 & 2 & 2 & 4 & 6 & 8\\8 & 6 & 4 & 2 & 2 & 4 & 6 & 8\\8 & 6 & 4 & 2 & 2 & 4 & 6 & 8\\5 & 5 & 5 & 5 & 5 & 5 & 5 & 5\\7 & 7 & 7 & 7 & 7 & 7 & 7 & 7\end{matrix}\right],
$$
and the pattern of the entries continues in this fashion for larger multiples of $4$.
Proof: We want to show that $A^2 \equiv 0 \pmod{n}$, i.e. $BCBC \equiv 0 \pmod n$. Replacing entries of a matrix with equivalent values modulo $n$ will not affect this result, so we rewrite the first column of $B$ as
$$
\left(1,3,\dots,\frac n2 - 1, 0,\dots,0,-(\frac n2 + 1),-(\frac n2 + 3),\dots, -1\right).
$$
With this, we find that the dot-product of the first column of $B$ and either row of $C$ is equal to $0$. Thus, the product $CB$ has the form
$$
CB \equiv \pmatrix{0&m_1\\0&m_2} \pmod{n}.
$$
The upper-right entry of the product $CB$ is given by
$$
\overbrace{1 + 1 + \cdots + 1}^{n/2} = \frac n2.
$$
The lower-right entry of the product $CB$ is given by
$$
2 \cdot (2 + 4 + \cdots + n/2) = 4 \cdot \frac{(n/4)(n/4 + 1)}{2} = \left( \frac n4 + 1\right)\frac n2.
$$
Thus, $m_1$ and $m_2$ are multiples of $n/2$. On the other hand, the entries of $r_2$ are all equal to a multiple of $2$.
Now, the product $CBC$ has rows $m_1 r_2$ and $m_2 r_2$. Because we can write
$$
m_i r_2 = \left(\frac n2\right)\left(\frac{m_i}{n/2}\right) \cdot 2 \left( \frac {r_2}2\right) = n\, \left(\frac{m_i}{n/2}\right)\left( \frac {r_2}2\right),
$$
we can conclude that $CBC$ has entries that are multiples of $n$. It follows that the same is true for $A^2 = B(CBC)$. That is, $A^2 \equiv 0 \pmod n$, which is what we wanted.
