Tasks 4-6 solved