Quite slow solution to 4.