The general solution to such puzzle is to write a general form of the function of $A$ and $B$ that the problem statement allows, and solve using the givens. So for example if we posit $f(A,B)=u\,A^2+v\,A\,B+w\,B^2+x\,A+y\,B+z$, we know $f(A,B)$ for 8 pairs of inputs, and that gives us 8 linear equations of the 6 unknowns $u$, $v$, $w$, $x$, $y$, $z$. If we find a solution to that, we have solved the puzzle.
Here the system goes:
and has (single) solution
Thus $f(A,B)=A\,B-A+6$, thus $f(9,66)=591$.
It's a simple matter with the right tools. Try it online!.
Here $f$ is so simple that it was probably possible to find the solution by intuition, trial and error. But why bother when there is math?
More seriously: this shows that using any second-degree polynomial of $A$ and $B$ does not make the problem hard. This generalizes to any degree and in any field, including finite, e.g. the integers modulo $p$. This has applications in crypto, e.g. Shamir secret sharing can be thought as a variant of that where we reconstruct the coefficients of a polynomial given enough examples.