Four. (50 points) Let $A$ and $B$ be two point sets on a plane, satisfying $A \cap B=\varnothing,|A|=|B|=n$, and no three points are collinear. Connect several line segments between sets $A$ and $B$, with each line segment having one endpoint in set $A$ and the other endpoint in set $B$, and at most one line segment between any two points. Let the set of all line segments be $S$. If set $S$ satisfies that for any point in set $A$ or $B$, there are at least $l$ line segments connected, then set $S$ is called "l-good". Determine the maximum value of $|S|$, such that removing any line segment, set $S$ is no longer l-good.
Let set $A$ have $s$ points that do not lead to $l$ edges, and $n-s$ points that exactly lead to $l$ edges. Let set $B$ have $t$ points that do not lead to $l$ edges, and $n-t$ points that exactly lead to $l$ edges.
Due to symmetry, we can assume $s \leq t$.
Let $A = A_{1} \cup A_{2}$, where $A_{1}$ is the set of all points in $A$ that exactly lead to $l$ edges, and $A_{2}$ is the set of the remaining points in $A$ after removing $A_{1}$. Let $B = B_{1} \cup B_{2}$, where $B_{1}$ is the set of all points in $B$ that exactly lead to $l$ edges, and $B_{2}$ is the set of the remaining points in $B$ after removing $B_{1}$.
Then $|S|$ satisfies the following two estimates:
(1) $|S| \leq (n-s) l + s(n-t)$.
Notice that the points in set $A_{2}$ can only be adjacent to points in set $B_{1}$, so for $a \in A_{2}$,
$d(a) \leq |B_{1}| = n-t$.
(2) $|S| \leq (n-s) l + l(n-t)$.
For any edge in set $S$, at least one endpoint is in set $A_{1}$ or $B_{1}$, therefore,
$|S| \leq (n-s) l + l(n-t)$.
From (1) and (2), we have
$|S| \leq (n-s) l + (n-t) \min \{s, l\}$
$\leq (n-s)(l + \min \{s, l\})$.
If $s > l$, then $|S| \leq (n-l) 2l$;
If $s \leq l$, then $|S| \leq (n-s)(s + l)$.
Thus, when $\left[\frac{n-l}{2}\right] \leq l$,
$|E| \leq \left(n - \left[\frac{n-l}{2}\right]\right)\left(\left[\frac{n-l}{2}\right] + l\right)$;
When $\left[\frac{n-l}{2}\right] > l$, $|S| \leq (n-l) 2l$, i.e.,
$|S| \leq \begin{cases}
(n-l) 2l, & \left[\frac{n-l}{2}\right] > l; \\
\left(n - \left[\frac{n-l}{2}\right]\right)\left(\left[\frac{n-l}{2}\right] + l\right), & \left[\frac{n-l}{2}\right] \leq l.
\end{cases}$
Construction: (i) If $\left[\frac{n-l}{2}\right] > l$, construct two complete bipartite graphs $K_{n-l, l}$, i.e., divide the points in set $A$ into two sets $A_{1}$ and $A_{2}$ ($|A_{1}| = n-l$, $|A_{2}| = l$); divide the points in set $B$ into two sets $B_{1}$ and $B_{2}$ ($|B_{1}| = l$, $|B_{2}| = n-l$), where each point in set $A_{1}$ is connected to each point in set $B_{1}$, and each point in set $A_{2}$ is connected to each point in set $B_{2}$.
(ii) If $\left[\frac{n-l}{2}\right] \leq l$, divide sets $A$ and $B$ as follows:
$$
\begin{array}{l}
A_{1} \cup A_{2} = A, \\
|A_{1}| = n - \left[\frac{n-l}{2}\right], |A_{2}| = \left[\frac{n-l}{2}\right]; \\
B_{1} \cup B_{2} = B, \\
|B_{1}| = n - \left[\frac{n-l}{2}\right], |B_{2}| = \left[\frac{n-l}{2}\right].
\end{array}
$$

At this point, connect each point in set $A_{1}$ to each point in set $B_{2}$, and connect each point in set $A_{2}$ to each point in set $B_{1}$. Then, construct a $(l - \left[\frac{n-l}{2}\right])$-regular bipartite graph between sets $A_{1}$ and $B_{1}$.