McCarthy fails to become speaker after three ballots