sub p{ my($n,@e,$o) = @_; print if ! $_{$_ = join$",sort@_,$/}++; p(++$o, --$n, @e) while $n-1; } p(shift)