public void tryNext(int n, int level, int[] pos, boolean[] used, boolean[] left, boolean[] right) {
        if(level == n) {
        	res++;
            return;
        }
        for(int i = 0; i < n; i++){
            if(!used[i] && !left[level - i + n] && !right[level + i]) {
                used[i] = true;
                pos[level] = i;
                left[level - i + n] = true;
                right[level + i] = true;
                tryNext(n, level+1, pos, used, left, right);
                left[level - i + n] = false;
                right[level + i] = false;
                used[i] = false;
            }
        }
    }