Nonequilibrium dynamics of quantum spin glass in an ac magnetic field