Solves first 8 problems