Valiant-Vazirani for smaller complexity classes