A system X is neither in thermal equilibrium with Y, nor with Z. The systems Y and Z
Let the temperatures of X, Y and Z be Tx, Ty and Tz, respectively.
Given, Tx ≠ Ty,
and Tx ≠ Tz.
This does not tell us anything about Ty and Tz, except that they are not equal to Tx.
So, Ty = Tz, and Ty ≠ Tz, both are possibilities!
So they can be in thermal equilibrium.