I'll rename, for simplicity: the first continued fraction I'll call "x", and the other I'll call "y".

Note that x = A + B/(A + (B/(A + B/...)))) = A + B/[A + B/(A + (B/(A + (B/...)))) = A + B/x. Similarly, y = B + A/y.

For these to be equal, we must have A + B/x = B + A/y. What can you get from this?