improved all-pairs, made item first/last appearance properties