For image formation due to M1,
1/f=1/u+1/v
Here f=20cm , u=30cm
So v=60cm
Let distance of S from M2 be x.
The image due to M1 acts as virtual object and this virtual object will be at a distance =60-(30+x)=30-x
For M2 f= -20cm , u= -(30-x)=x-30 and v= x
So using 1/f=1/u+1/v
We get x=20cm
a)So distance between two mirrors is 30+20 =50cm
b)Use 1/f=1/u+1/v
Here f= -20cm , u=20cm
So v= -10cm