dfs matrix permutation subset