$\newcommand{\diag}{\operatorname{diag}}$What is the minimum integer $N$ for which there exists two $N$ by $N$ matrices $X$ and $Y$ that satisfy the following conditions:
$$\diag(X)=\diag(XYY)=\diag(YXY)=\diag(YYX)\neq \mathbf{0}$$ $$\diag(Y)=\diag(XXY)=\diag(XYX)=\diag(YXX)\neq \mathbf{0}$$ $$\diag(XY)=\diag(YX)\neq \mathbf{0}$$ $$\diag(XXYY)=\diag(XYYX)=\diag(YYXX)=\diag(XYXY)=\diag(YXYX)\neq \mathbf{0}$$
and
$\diag(X)$, $\diag(Y)$, $\diag(XY)$, and $\diag(XXYY)$ have different values.
In particular does there exist any solution for $N\leq 3$?
In the above equations, $XY$ denotes matrix multiplication (or any similar operation that is distributive and associative), $\mathbf{0}$ is the $N$ by $1$ zero vector, and $\diag(X)$ denotes the diagonal of matrix $X$.
Note this question has another variant posted here.
For $N=3$, try $$X = \pmatrix{-1 & 0 & 0\cr 0 & -1 & 0\cr 0 & 0 & -1},\ Y = \pmatrix{1 & 0 & 0\cr 0 & 0 & 1\cr 0 & 1 & 0\cr}$$
EDIT: For $N=2$, $$X = \pmatrix{-1 & 0\cr 0 & -1},\ Y = \pmatrix{-1 & 0\cr 0 & 1\cr}$$