Constant-time quantum algorithm for homology detection in closed curves