restructured permutation generation