We'll obviously have to assume that all the quarter-turns are described in the same direction.

A single (anticlockwise) rotation through a quarter turn about the origin corresponds to multiplication by i. But for this problem there are two different centres of rotation, A and B. We can't put them both at the origin, so we need a more general setup.

Represent A, B, P by the complex numbers a, b, z. If you rotate z (anticlockwise) a quarter turn about a, it takes z to the point . If you rotate this new point a quarter turn about b, it takes it to the point .

If you now repeat both operations then you get the same formula again, except that z must be replaced by . So the funal position of z is given by . In other words, z ends up where it started from.