Turning charge-density waves into Cooper pairs