Solution :
The order of basicity is I > III > II > IV.
The lone pair of electrons on $$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.