def permutations(word):
    """Recursively generates permutations of word"""
    def _perms(i):
        if i == len(arr):
            res.append(arr[:])
        else:
            for j in range(i, len(arr)):
                arr[i], arr[j] = arr[j], arr[i]
                _perms(i+1)
                arr[i], arr[j] = arr[j], arr[i]
    res = []
    arr = list(word)
    _perms(0)
    return set(map("".join, res))