Added code for the 6th part.