4. The system of inequalities
$$
\left\{\begin{array}{l}
x^{2}-(7+m) x+7 m \leqslant 0, \\
x^{2}-(n+1) x+n \geqslant 0
\end{array}\right.
$$

has the solution set $5 \leqslant x \leqslant 7$. Then the values of $m, n$ are ( ).
(A) $\left\{\begin{array}{l}m=5, \\ n \leqslant 5\end{array}\right.$ or $\left\{\begin{array}{l}m \leqslant 5, \\ n=5\end{array}\right.$,
(B) $\left\{\begin{array}{l}m=5, \\ 1<n \leqslant 5\end{array}\right.$ or $\left\{\begin{array}{l}1<m \leqslant 5, \\ n=5\end{array}\right.$,
(C) $\left\{\begin{array}{l}m=5, \\ n \leqslant 5\end{array}\right.$ or $\left\{\begin{array}{l}1 \leqslant m \leqslant 5 \\ n=5\end{array}\right.$,
(D) None of the above answers are correct.
4. A

The system of inequalities can be transformed into
$$
\left\{\begin{array}{l}
(x-7)(x-m) \leqslant 0, \\
(x-1)(x-n) \geqslant 0 .
\end{array}\right.
$$
The solution set of (1) is $A_{1}=[m, 7]$ (when $m \leqslant 7$). Or $A_{2}=[7, m]$ (when $m>7$), and $A_{2}$ should be discarded. When $n \geqslant 1$, the solution set of (2) is $B_{1}=(-\infty, 1]$ or $B_{2}=[n, \infty)$, and $B_{1}$ should be discarded. When $n \leqslant 1$, the solution set of (2) is $B_{3}=(-\infty, n]$ or $B_{4}=[1, \infty)$, and $B_{3}$ should be discarded. According to the problem, we should have
(i) $A_{1} \cap B_{2}=[m, 7] \cap[n, \infty)=[5,7]$ $(n \geqslant 1)$. We can take $\left\{\begin{array}{l}m=5, \\ 1 \leqslant n \leqslant 5\end{array}\right.$ or $\left\{\begin{array}{l}m \leqslant 5, \\ n=5 .\end{array}\right.$
(ii) $A_{1} \cap B_{4}=[m, 7] \cap[1, \infty)=[5,7](n$ $\geqslant 1$ ). We should take $\left\{\begin{array}{l}m=5, \\ n \leqslant 1 .\end{array}\right.$ Combining these, we get $\mathrm{A}$.