S&P 500, Nasdaq post best quarter since 2020 with 14% gain