8. Given a convex $n(n \geqslant 4)$-sided polygon $M$, color $n-3$ diagonals green and the other $n-3$ diagonals red, such that diagonals of the same color do not intersect inside $M$. Find the maximum number of intersection points between the red and green diagonals inside $M$.
8. It is easy to obtain that in a convex $n$-gon, there are at most $n-3$ diagonals such that any two diagonals do not intersect inside the convex $n$-gon. These $n-3$ diagonals divide the convex $n$-gon into $n-2$ triangles, and at least two vertices do not have any diagonals drawn from them. Therefore, at least two diagonals cut off triangles from the $n$-gon.

For any diagonal $d$, let $f(d)$ be the number of intersection points of red diagonals and green diagonals on $d$. For any pair of green diagonals $d$ and $d'$, assume that there are $k$ vertices of $M$ (including the endpoints of $d$ and $d'$) between $d$ and $d'$. The remaining $n-k$ points form a convex polygon $A \cdots B C \cdots D$, where $A, B$ are the vertices adjacent to $d$ and not among the above $k$ vertices of $M$, and $C, D$ are the vertices adjacent to $d'$ and also not among the above $k$ vertices of $M$. $A, B$ may coincide, and $C, D$ may also coincide.
Let the number of red segments in the polygon $A \cdots B C \cdots D$ be $m$.
Since an $(n-k)$-gon has at most $(n-k-3)$ non-intersecting diagonals, we have $m \leq (n-k-3) + 2$, including $A D$ and $B C$ which may also be red.

Each of these $m$ red diagonals can intersect both $d$ and $d'$, while each of the remaining $(n-3-m)$ diagonals can intersect at most one of $d$ and $d'$. Therefore, we have
$$
\begin{array}{l}
f(d) + f(d') \leq 2m + (n-3-m) = n-3+m \\
\leq n-3 + n-k-1 = 2n-k-4.
\end{array}
$$

Take any two green diagonals that can cut off triangles from the $n$-gon $M$, and let these two diagonals $d_1, d_2$ be the first pair of diagonals; then select two more green diagonals that can cut off triangles from the remaining $(n-2)$-gon, and let them be $d_3, d_4$ as the second pair of diagonals; $\cdots \cdots \cdot d_{2r-1}, d_{2r}$ as the $r$-th pair of green diagonals. If $n-3$ is odd, then the last green diagonal remains unpaired.

After the $r$-th pair of diagonals, the polygon is reduced to an $(n-2r)$-gon, where two sides are paired, i.e., $d_{2r-1}, d_{2r}$, and the other sides are either sides of $M$ or green diagonals $d_1, d_2, \cdots, d_{2r-2}$.

Since the number of vertices of $M$ not inside $d_{2r-1}$ and $d_{2r}$ (including the endpoints of $d_{2r-1}$ and $d_{2r}$) is at most $2r$, the number of vertices of $M$ inside $d_{2r-1}$ and $d_{2r}$ (including the endpoints of $d_{2r-1}$ and $d_{2r}$) is $k_r \geq n-2r$.
By the previous conclusion, we have
$$
f(d_{2r-1}) + f(d_{2r}) \leq 2n - k_r - 4 \leq n + 2r - 4.
$$

If $n-3$ is even, then $d_1, d_2, \cdots, d_{n-3}$ are all green diagonals; if $n-3$ is odd, then the last unpaired green diagonal can intersect at most $n-3$ red diagonals.

Let $n-3 = 2l + \varepsilon, \varepsilon \in \{0,1\}$. Then the number of intersection points does not exceed
$$
\begin{array}{l}
\sum_{r=1}^{l}(n + 2r - 4) + \varepsilon(n-3) \\
= l(2l + \varepsilon - 1) + l(l + 1) + \varepsilon(2l + \varepsilon) \\
= 3l^2 + \varepsilon(3l + \varepsilon) = \left\lceil \frac{3}{4}(n-3)^2 \right\rceil.
\end{array}
$$

Here, $\lceil t \rceil$ denotes the smallest integer not less than $t$.
In particular, when $n=4$, the sum $\sum_{r=1}^{0}$ is undefined, and is defined as 0.
The following example shows that this value can be achieved.
Let $PQ$ and $RS$ be two sides of $M$, and the diagonals $QR$ and $PS$ do not intersect inside $M$, and satisfy the following conditions: Let $U$ be the boundary between $Q$ and $R$ (excluding $S$ and $P$), and $V$ be the boundary between $P$ and $S$. Then the absolute difference in the number of vertices of $M$ on $U$ and $V$ is at most 1.

Color the following diagonals green: Diagonal $PR$, and all diagonals connecting vertices of $P$ on $U$ and vertices of $R$ on $V$.

Color the following diagonals red: Diagonal $QS$, and all diagonals connecting vertices of $Q$ on $V$ and vertices of $S$ on $U$.
$$
\begin{array}{l}
\text{When } n=2k, \text{ the number of intersection points is} \\
(k-1) + k + \cdots + (2k-4) + (2k-3) + \\
(2k-4) + \cdots + k + (k-1) \\
= (2k-3) + \{(k-1) + (2k-4)\}(2k-4) - (k-1) + 1 \\
= 3k^2 - 9k + 7 = \left\lceil \frac{3}{4}(n-3)^2 \right\rceil. \\
\text{When } n=2k-1, \text{ the number of intersection points is} \\
(k-1) + k + \cdots + (2k-5) + (2k-4) + \\
(2k-5) + (2k-6) + \cdots + (k-1) + (k-2) \\
= \frac{(3k-5)(k-2)}{2} + \frac{(3k-7)(k-2)}{2} \\
= 3k^2 - 12k + 12 = \left\lceil \frac{3}{4}(n-3)^2 \right\rceil.
\end{array}
$$

In summary, the maximum number of intersection points that satisfy the conditions is
$$
\left\lceil \frac{3}{4}(n-3)^2 \right\rceil.
$$