There had been an earlier question about why iodide should both be a good leaving group and a good nucleophile. I find this bahavior difficult to understand. Why should the electrons of iodide be pulled toward its larger nucleus and away from a proton to explain its acidity and the electrons also to be able to attack another nucleophile?
When I have compared reaction rates of the halides, the rate changes the most for fluoride if the solvent is changed from protic to aprotic. Iodide is relatively less sensitive to similar solvent effects. This seems consistent with the solvation suggested by Schrödinger. Solvation (protonation) does explain why fluoride should change by a large amount. That leaves why iodide should be a good leaving group and a good nucleophile.
If we assume that iodide is a good nucleophile with or without solvent effects, then it follows that S>O and P>N. I think that is correct and your answer book is correct.
The explanation that I find most suitable is one based upon polarizability. This is how I rationalize it. The acidity is a thermodynamic effect. The larger charge of the iodide nucleus should pull its electrons in more and increases the acidity. Although this does occur, electrons are not stationary, their position is not fixed. The inner electrons also create a repulsive force to the outer electrons. If we rationalize this could result in electrons temporarily taking excursions further from the nucleus, then the atoms may have both a thermodynamic and kinetic effect. As a thermodynamic effect, it can be more acidic and as a kinetic effect, be more nucleophilic.