static LL allPermutations(L l) {
new LL out;
allPermutations_impl(cloneList(l), l(l), out);
ret out;
}
static void allPermutations_impl(L l, int n, LL out) {
if (n <= 1) {
ping();
out.add(cloneList(l));
} else for(int i = 0; i < n; i++) {
allPermutations_impl(l, n-1, out);
swapElements(l, n % 2 == 0 ? i : 0, n-1);
}
}