from collections import defaultdict
class Solution:
    def numSpecialEquivGroups(self, A):
        """
        :type A: List[str]
        :rtype: int
        """
        if A==[]:
            return 0
        stack = []
        for i in range(len(A)):
            dict1,dict2={},{}
            for j in range(len(A[i])):
                if j%2==0:
                    if A[i][j] not in dict1:
                        dict1[A[i][j]]=1
                    else:
                        dict1[A[i][j]]+=1
                else:
                    if A[i][j] not in dict2:
                        dict2[A[i][j]]=1
                    else:
                        dict2[A[i][j]]+=1
            if (dict1,dict2) not in stack:
                stack.append((dict1,dict2))
        return len(stack)
s=Solution()
A=["abc","acb","bac","bca","cab","cba"]
print(s.numSpecialEquivGroups(A))


