Solution of task1