Given reaction is disproportionation reaction, same species is oxidised and reduced in the same reaction. Formation of sodium thiosulphate (Na2S2O3) is favoured when there is more NaOH in the solution.
1S8
Octasulphur
+
12NaOH
Sodiumhydroxide
⟶
4Na2S
Sodiumsulphide(P)
+
2Na2S2O3
Sodiumthiosulphate(Q)
+
6H2O
Water
Here, a=1,b=12,q=2 and r=6. Hence, product P is Na2S (sodium sulphide) and Q is Na2S2O3 (sodium thiosulphate).