private static boolean isValid(int[][] array, int size) {
        boolean[] found = new boolean[size*size];
        for (int i = 0; i < size*size; i++) {
            
            //rows
            for (int j = 0; j < size*size; j++) {
                found[array[i][j] - 1] = true;
            }
            for (int x = 0; x < found.length; x++) {
                if (!found[x]) {
                    System.out.println("A: i = " + i + ", n = " + (x+1));
                    return false;
                }
                found[x] = false;
            }
            
            for (int j = 0; j < size*size; j++) {
                found[array[j][i] - 1] = true;
            }
            for (int x = 0; x < found.length; x++) {
                if (!found[x]) {
                    System.out.println("B: i = " + i + ", n = " + (x+1));
                    return false;
                }
                found[x] = false;
            }
        }
        return true;
    }