The order of basicity is $\mathrm{I}>\mathrm{III}>\mathrm{II}>\mathrm{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 e $^{-} s$ on $N$ -atom is contributed towards the aromatic sextet formation and hence is not at all available for protonation. Hence option (b) is correct.