exercise 2.40 unique-pairs