4. Let the set
$S=\left\{m \mid m \in \mathbf{Z}_{+}, \text{ each prime factor of } m \text{ is less than 10}\right\}$.

Find the smallest positive integer $n$, such that any $n$-element subset of $S$ contains four distinct numbers whose product is a perfect square.
Notice the positive integers
$$
\begin{array}{l}
1,2,3,5,7,2 \times 3 \times 5 \times 7, \\
2^{3} \times 3 \times 5 \times 7,2 \times 3^{3} \times 5 \times 7
\end{array}
$$

Among them, the product of any four numbers is not a perfect square, which indicates that the smallest positive integer $n \geqslant 9$.

Next, prove: In any nine-element subset of $S$, there exist four numbers that satisfy the requirement of the problem.