Implement pairwise Xy for training data