4. Let $n$ be a positive integer greater than 3, and $(n, 3)=1$. Find the value of $\prod_{k=1}^{m}\left(1+2 \cos \frac{2 a_{k} \pi}{n}\right)$, where $a_{1}, a_{2}, \cdots$, $a_{m}$ are all positive integers not exceeding $n$ and coprime with $n$.
Given: $a_{1}, a_{2}, \cdots, a_{m}$ and $3 a_{1}, 3 a_{2}, \cdots, 3 a_{m}$ are both reduced residue systems modulo $n$.
Using $1+2 \cos 2 \theta=\frac{\sin 3 \theta}{\sin \theta}$, we get
$$
\begin{array}{l}
\left|\prod_{k=1}^{m} \sin \frac{a_{k} \pi}{n}\right|=\left|\prod_{k=1}^{m} \sin \frac{3 a_{k} \pi}{n}\right| \\
\quad=\left|\prod_{k=1}^{m} \sin \frac{a_{k} \pi}{n}\right|\left|\prod_{k=1}^{m}\left(1+2 \cos \frac{2 a_{k} \pi}{n}\right)\right|,
\end{array}
$$

where, $\prod_{k=1}^{m} \sin \frac{a_{k} \pi}{n} \neq 0$.
$$
\begin{array}{l}
\text { Also, } \prod_{k=1}^{m}\left(1+2 \cos \frac{2 a_{k} \pi}{n}\right) \\
=\prod_{k=1}^{\frac{m}{2}}\left(1+2 \cos \frac{2 a_{k} \pi}{n}\right)^{2} \geqslant 0, \\
\text { hence } \prod_{k=1}^{m}\left(1+2 \cos \frac{2 a_{k} \pi}{n}\right)=1 .
\end{array}
$$