Preserving quantum coherence via random modulation