store the distance matrix