When switch S is closed magnetic field lines passing through Q increases in the direction from right to left. So, according to Lenz’s law induced current in Q i.e. IQ1 will flow in such a direction so that the magnetic field lines due to IQ2 passes from left to right through Q. This is possible when IQ1 flows in anticlockwise direction as seen by E. Opposite is the case when switch S is opened i.e. IQ2 will be clockwise as seen by E.