Solution to task 1