Basicity ∝ electron pair intensity on nitrogen.
(III) Refer image .1 No resonance and +I effect from both sides ∴ most basic.
(II) Refer image.2 Nitrogen do not involve in resonance ∴ more basic.
(I) Refer image.3 Nitrogen lone pair is involved in resonance.
Therefore less available for donation. . . less basic.
(IV) Refer image. 4 6πe−, Aromatic nitrogen lone pair participating in aromaticity ∴ less available for donation. ∴ least basic. ∴ III > II > I > IV (Basicity order)