n=int(eval(input()))

dic={}

for i in range(n):

  wk={}

  s=eval(input())

  for i in range(len(s)):

    if s[i] in wk:

      wk[s[i]]+=1

    else:

      wk[s[i]]=1

  list=sorted(list(wk.items()),key=lambda x:x[0])

  key="".join(map(str,list(dict(list).items())))

  if key in dic:

    dic[key]+=1

  else:

    dic[key]=1

ans=0

for i in list(dic.values()):

  if i==1:

    continue

  else:

    ans+=i*(i-1)/2

print((int(ans)))
n=int(eval(input()))

dic={}

for i in range(n):

  wk={}

  s=eval(input())

  for i in range(len(s)):

    if s[i] in wk:

      wk[s[i]]+=1

    else:

      wk[s[i]]=1

  list=sorted(list(wk.items()),key=lambda x:x[0])

  key="".join(map(str,list))

  if key in dic:

    dic[key]+=1

  else:

    dic[key]=1

ans=0

for i in list(dic.values()):

  if i==1:

    continue

  else:

    ans+=i*(i-1)/2

print((int(ans)))
n = int(eval(input()))
dic = {}
for i in range(n):
    wk = {}
    s = eval(input())
    for i in range(len(s)):
        if s[i] in wk:
            wk[s[i]] += 1
        else:
            wk[s[i]] = 1
    list = sorted(list(wk.items()), key=lambda x: x[0])
    key = "".join(map(str, list(dict(list).items())))
    if key in dic:
        dic[key] += 1
    else:
        dic[key] = 1
ans = 0
for i in list(dic.values()):
    if i == 1:
        continue
    else:
        ans += i * (i - 1) / 2
print((int(ans)))

n = int(eval(input()))
dic = {}
for i in range(n):
    wk = {}
    s = eval(input())
    for i in range(len(s)):
        if s[i] in wk:
            wk[s[i]] += 1
        else:
            wk[s[i]] = 1
    list = sorted(list(wk.items()), key=lambda x: x[0])
    key = "".join(map(str, list))
    if key in dic:
        dic[key] += 1
    else:
        dic[key] = 1
ans = 0
for i in list(dic.values()):
    if i == 1:
        continue
    else:
        ans += i * (i - 1) / 2
print((int(ans)))

-    key = "".join(map(str, list(dict(list).items()))) +    key = "".join(map(str, list))