nicer, more generic implementation to generate all pairs for binary variables