When switch is closed, current in P grows. Induced current is S will oppos the growth. Hence the current in S must be anticlockwise. When switch is opened, current in P dacays from maximum to zero. Induced current in S will oppose the decay. Hence current in S must be clockwise.