Step 1: (4) “All devils are nasty” means devils ⊆ nasty.
Step 2: (5) “Some nasty are devils” is consistent with (4).
Step 3: (3) “All witches are devils” places witches inside devils, and therefore inside nasty.
No contradictions arise, so 4, 5, 3 is correct.