Classifying matrices separating rows and columns