I'm struggling to understand how the Chinese remainder theorem works on quadratics (though I know how it works in the simpler cases). For example in my number theory book there's an example with $f(x) = x^{2} + x + 7$ and we need to find all the solutions to $f(x) \equiv 0$ (mod $189$) given that the roots mod $27$ are $4, 13, 22$ and the roots mod $7$ are $0$ and $6$.
There's a solution in the book to the example but I can't understand it very well. It says: "...we find that $x \equiv a_{1}$ (mod $27$) and $x \equiv a_{2}$ mod($7$) if and only if $x \equiv 28 \cdot a_{1} - 27 \cdot a_{2}$ (mod $189$)."
And then the solution (there are six) follows easily by plugging in the solutions provided in the mod $27$ and mod $7$ cases listed above.
But my main struggle is understanding how this equation $x \equiv 28 \cdot a_{1} - 27 \cdot a_{2}$ (mod $189$) was derived, and how to get this equation in general for these problems (I think it involves Chinese remainder theorem and Euclidean algorithm but I can't figure it out).