no more than 2 sets in sets[0:D - 1] is possible to be non-empty