Clustering and Inference From Pairwise Comparisons