Four. (50 points) Let $M=\{1,2, \cdots, 10\}$. For a partition of $M$ into $A_{1}, A_{2}, A_{3}$ (all $A_{i}$ are non-empty), if there exists a permutation $A_{i 1}, A_{i 2}, A_{i 3}$ of $A_{1}, A_{2}, A_{3}$ such that
$$
\max A_{i k}>\min A_{i, k+1}\left(k=1,2,3, A_{i 4}=A_{i 1}\right) \text {, }
$$
then it is called a "good" partition. Find the number of all good partitions of $M$.
First, let's state a basic fact about the number of 3-partitions of $M$ as a lemma.

Lemma Let $P=\left\{\left\{A_{1}, A_{2}, A_{3}\right\}\right.$ 1 non-empty sets $A_{1}$, $A_{2}$, $A_{3}$ are a partition of $M$ $\}$. Then
$$
|P|=\frac{1}{6}\left(3^{10}-3 \times 2^{10}+3\right)=9330 \text {. }
$$

Proof In fact, first calculate the system of set equations
$$
\left\{\begin{array}{l}
M=A_{1} \cup A_{2} \cup A_{3}, \\
A_{i} \cap A_{j}=\varnothing(1 \leqslant i < j \leqslant 3)
\end{array}\right.
$$
If $10 \notin A$, assume without loss of generality that $10 \in B$. Suppose (i) and (ii) do not hold, then there exists $i$ such that $\max B < \min A$ and $\max A < \min C$, or $\max C < \min B$. If $\max B < \min A$, then the cyclic permutation $\{A, B, C\}$ satisfies the definition of a good partition, a contradiction. If $\max A < \min C$ and $\max C < \min B$, then the cyclic permutation $\{A, C, B\}$ satisfies the definition of a good partition, a contradiction. This proves that a non-good partition must satisfy at least one of (i) or (ii).
Next, calculate the number of non-good partitions.
The number of partitions satisfying (i) is
$$
\frac{1}{2} \sum_{k=1}^{8}\left(2^{10-k}-2\right)=2^{9}-10 \text {, }
$$

The number of partitions satisfying (ii) is
$$
\frac{1}{2} \sum_{l=3}^{10}\left(2^{l-1}-2\right)=2^{9}-10 \text {, }
$$

The number of partitions satisfying both (i) and (ii) is $\mathrm{C}_{9}^{2}$.
Therefore, by the principle of inclusion-exclusion, the number of non-good partitions where all three sets are non-empty is
$$
2\left(2^{9}-10\right)-\mathrm{C}_{9}^{2}=968 \text {. }
$$

Applying the lemma, the number of good partitions is
$$
|P|-968=9330-968=8362 .
$$