After learning a lot about space exploration, a little girl named Ana wants to change the subject.

Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she came up with a more interesting one and she needs your help to solve it:

You are given an array of strings which consist of only small letters of the alphabet. Your task is to find how many palindrome pairs are there in the array. A palindrome pair is a pair of strings such that the following condition holds: at least one permutation of the concatenation of the two strings is a palindrome. In other words, if you have two strings, let's say "aab" and "abcac", and you concatenate them into "aababcac", we have to check if there exists a permutation of this new string such that it is a palindrome (in this case there exists the permutation "aabccbaa"). 

Two pairs are considered different if the strings are located on different indices. The pair of strings with indices $(i,j)$ is considered the same as the pair $(j,i)$.


-----Input-----

The first line contains a positive integer $N$ ($1 \le N \le 100\,000$), representing the length of the input array.

Eacg of the next $N$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array. 

The total number of characters in the input array will be less than $1\,000\,000$.


-----Output-----

Output one number, representing how many palindrome pairs there are in the array.


-----Examples-----
Input
3
aa
bb
cd

Output
1

Input
6
aab
abcac
dffe
ed
aa
aade

Output
6



-----Note-----

The first example:  aa $+$ bb $\to$ abba. 

The second example:  aab $+$ abcac $=$ aababcac $\to$ aabccbaa aab $+$ aa $=$ aabaa abcac $+$ aa $=$ abcacaa $\to$ aacbcaa dffe $+$ ed $=$ dffeed $\to$ fdeedf dffe $+$ aade $=$ dffeaade $\to$ adfaafde ed $+$ aade $=$ edaade $\to$ aeddea

Difficulty: competition

Starter code:

Solutions:
#!/usr/bin/env python3
"""
Created on Wed Feb 28 11:47:12 2018

@author: mikolajbinkowski
"""
import sys

N = int(input())

string_count = {}
for _ in range(N):
    s = str(input())
    char_count = {}
    for c in s:
        char_count[c] = char_count.get(c, 0) + 1
    s0 = []
    for a in 'abcdefghijklmnopqrstuvwxyz':
        if char_count.get(a, 0) % 2 == 1:
            s0.append(a)
    s1 = ''.join(s0)
    string_count[s1] = string_count.get(s1, 0) + 1

pairs = 0
for s, v in list(string_count.items()):
    pairs += v * (v-1) // 2
    for i in range(len(s)):
        pairs += v * string_count.get(s[:i] + s[i+1:], 0)

print(pairs)

        
    


def main():
    n = int(input())
    ans = 0
    d = {}
    for i in range(n):
        s = input()
        cur = 0
        for c in s:
            cur ^= (1 << (ord(c) - ord('a')))
        ans += d.get(cur, 0)
        for j in range(26):
            ans += d.get(cur ^ (1 << j), 0)
        t = d.get(cur, 0) + 1
        d[cur] = t
    print(ans)
    return

def __starting_point():
    main()
__starting_point()

# -*- coding:utf-8 -*-

"""

created by shuangquan.huang at 11/20/18



After learning a lot about space exploration, a little girl named Ana wants to change the subject.

Ana is a girl who loves palindromes (string that can be read the same backwards as forward).
She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem,
so she came up with a more interesting one and she needs your help to solve it:

You are given an array of strings which consist of only small letters of the alphabet.
Your task is to find how many palindrome pairs are there in the array.
A palindrome pair is a pair of strings such that the following condition holds:
at least one permutation of the concatenation of the two strings is a palindrome.
In other words, if you have two strings, let's say "aab" and "abcac",
and you concatenate them into "aababcac", we have to check if there exists a permutation of this new string such that
it is a palindrome (in this case there exists the permutation "aabccbaa").

Two pairs are considered different if the strings are located on different indices.
The pair of strings with indices (𝑖,𝑗) is considered the same as the pair (𝑗,𝑖).

Input
The first line contains a positive integer 𝑁 (1≤𝑁≤100 000), representing the length of the input array.

Eacg of the next 𝑁 lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array.

The total number of characters in the input array will be less than 1000000.

Output
Output one number, representing how many palindrome pairs there are in the array.



# a, b can be transform to palindrome only when number of every characters in a+b is even, or only one is odd.
# only odd+even => odd


"""

import collections

N = int(input())


def hash(s):
    wc = collections.Counter(s)
    x = ''
    for i in range(26):
        w = chr(ord('a') + i)
        c = wc[w]
        if c % 2 == 0:
            x += '0'
        else:
            x += '1'
    
    return x


def neighbor(s):
    for i in range(len(s)):
        yield s[:i] + ('1' if s[i] == '0' else '0') + s[i + 1:]


def isneighbor(a, b):
    return sum([0 if a[i] == b[i] else 1 for i in range(len(a))]) == 1

m = collections.defaultdict(list)
for i in range(N):
    s = input()
    m[hash(s)].append(i)

even = 0
odd = 0
for k, v in list(m.items()):
    lv = len(v)
    even += lv * (lv - 1) // 2
    
    for b in neighbor(k):
        if b in m:
            odd += lv * len(m[b])

print(even + odd // 2)



from collections import Counter

n = int(input())

mp = Counter({'': 0})

for i in range(n):
    string = input()
    occ = [0] * 26
    for c in string:
        occ[ord(c) - ord('a')] += 1
        if occ[ord(c) - ord('a')] == 2:
            occ[ord(c) - ord('a')] = 0
    clean = []
    for idx in range(26):
        while occ[idx] > 0:
            clean.append(chr(idx + ord('a')))
            occ[idx] -= 1

    mp[''.join(clean)] += 1

ans = 0


def combs(n):
    return n * (n - 1) // 2


for key in mp:
    if len(key) == 1:
        ans += combs(mp[key]) + mp[key] * mp['']
    elif len(key) == 0:
        ans += combs(mp[key])
    else:
        ans += combs(mp[key])
        for idx in range(len(key)):
            ans += mp[key] * mp[key[0:idx] + key[idx + 1:]]

print(ans)


from collections import Counter

n = int(input())
strings = []

for i in range(0,n):
  counter = { x: 0 for x in range(ord('a'), ord('z')+1) }
  napis = input()
  for val in napis:
    counter[ord(val)] = (counter[ord(val)] + 1) % 2
  
  napis = ""
  for key, val in list(counter.items()):
    if val != 0:
      napis+=chr(key)
  
  strings.append(napis)

c = Counter(strings)
strings = sorted(c.most_common(), key=lambda i: i[0])
#print(strings)

count = 0
for key, val in strings:
  if val > 1:
    count += val*(val-1)/2

for charInt in range(ord('a'), ord('z')+1):
  char = chr(charInt)
  copy = {}
  for key, val in strings:
    if char in key:
      copy[key.replace(char, "")] = copy.get(key.replace(char, ""), 0) + val
  #print(copy)
  for key, val in strings:
    if copy.get(key,0) != 0:
      count+=val * copy[key]
      #print("pokrywa : ", key, " ", val*copy[key])

print(int(count))


n = int(input())
string_count = {}
for _ in range(n):
    s = str(input())
    item_count={}
    for i,c in enumerate(s):
        item_count[c]=item_count.get(c,0)+1
    s0=[]
    for i,x in enumerate('abcdefghijklmnopqrstuvwxyz'):
        if item_count.get(x,0)%2==1:
            s0.append(x)
    s1 = ''.join(s0)
    string_count[s1]=string_count.get(s1,0)+1
points=0
for j,a in enumerate(string_count):
    x = string_count[a]
    points+=x*(x-1)//2
    for i in range(len(a)):
        points+=x*string_count.get(a[:i]+a[i+1:],0)
print(points)

n = int(input())
string_count = {}
for _ in range(n):
    s = str(input())
    item_count={}
    for i,c in enumerate(s):
        item_count[c]=item_count.get(c,0)+1
    s0=[]
    for x in 'abcdefghijklmnopqrstuvwxyz':
        if item_count.get(x,0)%2==1:
            s0.append(x)
    s1 = ''.join(s0)
    string_count[s1]=string_count.get(s1,0)+1
points=0
for a,x in string_count.items():
    points+=x*(x-1)//2
    for i in range(len(a)):
        points+=x*string_count.get(a[:i]+a[i+1:],0)
print(points)

n=int(input())
s=[0]*n
for i in range (n):
    s[i]=input()
dic={}
ans=0
for i in range (n):
    temp=0
    for k in range(len(s[i])):
        temp^=(1<<(ord(s[i][k])-ord('a')))
    #print(temp,s[i])
    if temp in list(dic.keys()):
        ans=ans+dic[temp]
    for j in range (26):
        chk=temp
        chk^=(1<<j)
        if chk in list(dic.keys()):
            ans=ans+dic[chk]
    if temp in list(dic.keys()):
        dic[temp]+=1
    else:
        dic[temp]=1
   # print(dic[temp])
print(ans)


aw=[2**i for i in range(26)]
n=int(input())
d=dict()
ans=0
for ir in range(n):
    st=input()
    es=0
    for j in st:
        es=es^aw[ord(j)-97]
    if es in d:
        ans+=d[es]
    for j in range(26):
        es=es^aw[j]
        if es in d:
            ans+=d[es]
        es=es^aw[j]
    if es in d:
        d[es]+=1
    else:
        d.update({es:1})
print(ans)


import sys

input = sys.stdin.readline


def gcd(a, b):
    if a == 0:
        return b
    return gcd(b % a, a)


def lcm(a, b):
    return (a * b) / gcd(a, b)




def main():
    comp=[]
    c=1
    for i in range(27):
        comp.append(c)
        c*=2
    n=int(input())
    d={}
    table=[]
    for i in range(n):
        k=[0]*27
        s=input()
        for j in s:
            if ord(j)-ord('a')>=0:
                k[ord(j)-ord('a')]+=1
            #print(ord(j)-ord('a'))
        key=0
        for i in range(26):
            if k[i]%2:
                key+=comp[i]
        table.append([k,key])
        if key in d:
            d[key]+=1
        else:
            d[key]=1
    ans=0
    for i in list(d.values()):
        ans+=(i)*(i-1)//2
    #print(ans)
    for i in table:
        #print(i)
        for j in range(len(i[0])):
            if i[0][j]%2:
                if i[1]-comp[j] in list(d.keys()):
                    #print(i[1],i[1]-comp[j] )
                    ans+=(d[i[1]-comp[j]])

    print(int(ans))


    return


def __starting_point():
    main()

__starting_point()