All-pairs generator