boolean isValid(int lvl, int j) {
        for (int i = 0; i < lvl; i++) {

            // check vertical
            if (line[i] == j) return false;

            // check cross
            if (Math.abs(lvl - i) == Math.abs(line[i] - j)) return false;
        }
        return true;
    }