Can someone help me prove the following identity?
$$
\mathop{\mathrm{Tr}}\left(\prod_{j=0}^{n-1}\begin{pmatrix}  
2\cos\frac{2j\pi}{n} & -m \\
1 & 0
\end{pmatrix}\right)=
\begin{cases}
2 & \text{if } n=1\pmod{2}\\
2m^{\frac{n}{2}} & \text{if } n=0\pmod{4}\\
-2m^{\frac{n}{2}}-4 & \text{if } n=2\pmod{4}\\
\end{cases},
$$

For the 1st equality, since the product of $2\cos\frac{2j\pi}{n}$'s is 2 when $n$ is odd, we only need to prove that the trace is a constant polynomial in $m$. However, because of the cosine term, the approach of polynomial analysis given in [my previous post] [1] does not seem to work here. 

Situations are the same for the 2nd and 3rd equalities.
[1]:https://mathoverflow.net/questions/213246/product-of-a-finite-number-of-matrices-related-to-roots-of-unity