Because the wires are directly connected to the two poles of the power supply, the current is very large at this time, so the power-on time should be minimized and the switching time should be short.
So the answer is: when the wire AB is stationary, it is parallel to the direction of the small magnetic needle; Turn off the switch for a short time.