On pairs of multidimensional matrices