Tunnel magnetoresistance of quantum dots coupled to ferromagnetic leads in the sequential and cotunneling regimes