The order of basicity is I $>$ III $>$ II $>$ IV The lone pair of electrons on $\mathrm{N}$ is more readily available for protonation in I and III then in II. III contains an oxygen atom which has - I effect due to which it is less basic than I. In compound IV lone pair of $\mathrm{e}^{-} \mathrm{s}$ on $\mathrm{N}$-atom is contributed towards the aromatic sextet formation and hence is not at all available for protonation. Hence option (b) is correct.