check that `n < pairs.size()`