Solution to part 5