n=int(eval(input()))

s=[]

ans=0

count=1

def comb(n,k):

  for i in range(k-1):

    n*=n-i-1

    k*=k-i-1

  return n//k



for i in range(n):

  a=list(eval(input()))

  a.sort()

  " ".join(a)

  s.append(" ".join(a))

s.sort()

for i in range(n-1):

  if s[i]==s[i+1]:

    count+=1

  else:

    ans+=(comb(count,2))

    count=1

if count>0:

  ans+=(comb(count,2))

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

ans=dict()

for i in range(n):

  d=list(eval(input()))

  d.sort()

  s="".join(d)

  if not(s in ans):

    ans[s]=1

  else:

    ans[s]+=1

anss=0

for i in ans:

  anss+=((ans[i]*(ans[i]-1))//2)

print(anss)
n = int(eval(input()))
s = []
ans = 0
count = 1


def comb(n, k):
    for i in range(k - 1):
        n *= n - i - 1
        k *= k - i - 1
    return n // k


for i in range(n):
    a = list(eval(input()))
    a.sort()
    " ".join(a)
    s.append(" ".join(a))
s.sort()
for i in range(n - 1):
    if s[i] == s[i + 1]:
        count += 1
    else:
        ans += comb(count, 2)
        count = 1
if count > 0:
    ans += comb(count, 2)
print(ans)

n = int(eval(input()))
ans = dict()
for i in range(n):
    d = list(eval(input()))
    d.sort()
    s = "".join(d)
    if not (s in ans):
        ans[s] = 1
    else:
        ans[s] += 1
anss = 0
for i in ans:
    anss += (ans[i] * (ans[i] - 1)) // 2
print(anss)

-s = [] -ans = 0 -count = 1 - - -def comb(n, k): -    for i in range(k - 1): -        n *= n - i - 1 -        k *= k - i - 1 -    return n // k - - +ans = dict() -    a = list(eval(input())) -    a.sort() -    " ".join(a) -    s.append(" ".join(a)) -s.sort() -for i in range(n - 1): -    if s[i] == s[i + 1]: -        count += 1 +    d = list(eval(input())) +    d.sort() +    s = "".join(d) +    if not (s in ans): +        ans[s] = 1 -        ans += comb(count, 2) -        count = 1 -if count > 0: -    ans += comb(count, 2) -print(ans) +        ans[s] += 1 +anss = 0 +for i in ans: +    anss += (ans[i] * (ans[i] - 1)) // 2 +print(anss)