Solutions to first two tasks