Given a system of equations

> 
> $A^2 + B^2 = 5$
> 
> 
> $AB = 2$
> 
> 
> 

what is the correct way to solve it?

I see immediately that the answers are

1. $A=1, B=2$
2. $A=2, B=1$
3. $A=-1, B=-2$
4. $A=-2, B=-1$

but I don't understand the correct way of getting there. I have tried to isolate one of the variables and put the resulting expression into one of the equations, but this didn't get me anywhere. What is the correct way of solving this problem?