Lemma: Let $p(x)$ be a polynomial (over $\mathbb{R}[x]$ say) and let $a\in\mathbb{R}$. Then, the remainder of division of $p(x)$ by $x-a$ is $p(a)$.
Proof. Let $q(x)$ and $r(x)$ be the quotient and remainder of the division of $p(x)$ by $x-a$. Then, the degree of $r(x)$ must be $0$, i.e., $r(x)=r$ is a constant, and
$$p(x)=q(x)(x-a)+r.$$
Therefore, if we evaluate the displayed expression at $a$, we obtain
$$p(a)=q(a)(a-a)+r=0+r=r.$$
Hence, $r=p(a)$ as claimed.
Example. Let $p(x)=mx^3-nx^2+5x-1$, and suppose that the remainder when divided by $x+2$ is $-39$, and the remainder when divided by $x-1$ is $3$. By our Lemma, this implies that $p(-2)=-39$ and $p(1)=3$. Hence,
$$-8m-4n-11=-39 \ \text{ and } \ m-n+4=3,$$
or, equivalently,
$$2m+n=4\ \text{ and } \ m-n=-1.$$
Hence, $n=m+1$, and $4=2m+m+1$ so $3m=3$. Thus, $m=1$, and $n=2$.