Solutions to tasks 1 to 3.