static void nQueenHelper(char[][]b, boolean[][]u, int i, ArrayList<ArrayList<String>>rel) {
        int n=b.length;
        if (i==n) {
            ArrayList<String> c=new ArrayList<>();
            for (int j=0;j<b.length;++j)
                c.add(new String(b[j]));
            rel.add(c);
            return;
        }
        for (int j=0;j<n;++j) {
            if (u[0][j]||u[1][i+j]||u[2][n-i-1+j])
                continue;
            u[0][j]=u[1][i+j]=u[2][n-i-1+j]=true;
            b[i][j]='Q';
            nQueenHelper(b,u,i+1,rel);
            u[0][j]=u[1][i+j]=u[2][n-i-1+j]=false;
            b[i][j]='.';
        }
    }