Added implementation for permutations