import java.util.LinkedHashSet;
public class Program
{
public static void printPermutationRows(int matrix[][], int givenrow) {
int rows = matrix.length;
int cols = matrix[0].length;
LinkedHashSet<Integer> Set = new LinkedHashSet<>();
for (int j = 0; j < cols; j++) {
Set.add(matrix[givenrow][j]);
}
for (int i = 0; i < rows; i++) {
if (i == givenrow) {
continue;
}
int j;
for (j = 0; j < cols; j++) {
if (!Set.contains(matrix[i][j])) {
break;
}
}
if (j != cols) {
continue;
}
System.out.print(i + ", ");
}
}
public static void main(String[] args)
{
int givenrow = 1;
int matrix[][] = {
{7, 9, 4, 3, 1},
{4, 7, 9, 1, 3},
{4, 7, 8, 1, 2},
{1, 6, 9, 7, 4},
{9, 1, 3, 7, 4},
};
printPermutationRows(matrix, givenrow);
}
}
/*
run:
0, 4,
*/