collision

As the Rohan is also taking part in the CodeWealth Series, this week he learned about hashing. Now he wants to practice some problems. So he came up with a simple problem. Firstly, he made a hash function F such that:

F(x) = x % 10

Now using this function he wants to hash N integers and count the number of collisions that will occur while hashing the integers.

Input:

The first line contains an integer T, denoting the number of test cases.

The first line of each test case contains an integer N, denoting the number of integers to hash.

The next line contains N space separated integers, denoting the integer X to hash.

Output:

For each test case, print the number of collisions that will occur while hashing the integers.

Constraints:

1 ≤ T ≤ 10

1 ≤ N ≤ 100

0 ≤ X ≤ 105

SAMPLE INPUT
2
3
1 2 3
4
1 1 2 3

SAMPLE OUTPUT
0
1

Explanation

In the first case, there will be no collisions as each integer will be hashed to a different index.

F(1) = 1 % 10 = 1

F(2) = 2 % 10 = 2

F(3) = 3 % 10 = 3

In the second case, there will be 1 collision at index 1 as the first two integers will hash to the same index.

Source: hackerearth | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
for _ in range(eval(input())):
	n=eval(input())
	a=list(map(int,input().split()))
	c=[0]*100001
	for i in range(n):
		c[a[i]%10]+=1
	s=0
	for i in range(max(a)+1):
		if(c[i]):
			s+=(c[i]-1)
	print(s)


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
t=eval(input())
while t>0:
	t-=1
	n=eval(input())
	l=[int(i) for i in input().split()]
	p=[]
	for i in l:
		p.append(i%10)
	print(len(p)-len(set(p)))


t = int(input())
while t>0:
	arr = [0,0,0,0,0,0,0,0,0,0]
	n = int(input())
	line  = list(map(int,input().split(" ")))
	for x in range(0,n):
		arr[line[x]%10]+=1
	
	collision =0
	for x in range(0,10):
		if arr[x]>0:
			collision+=arr[x]-1
	print(collision)	
	t-=1


def hashing():
	for _ in range(eval(input())):
		count = 0
		Y = []
		N = input()
		X = list(map(int, input().split()))
		
		for i in X:
			g = i%10
			if g not in Y:
				Y.append(g)
			else:
				count += 1
		
		print(count)

if __name__ == "__main__":
	hashing()


for _ in range(eval(input())):
	n=eval(input())
	s=list(map(int,input().split()))
	count=0
	c=""
	for i in range(n):
		x=s[i]%10
		x=str(x)
		if x not in c:
			c+=x
		else:
			count+=1
	print(count)



from sys import stdin

nextint = iter(map(int, stdin.read().split())).__next__
for x in range(nextint()):
	n = nextint()
	counter = [0]*10
	for x in range(n):
		counter[nextint() % 10] += 1
	print(sum([counter[x] - 1 for x in range(10) if counter[x] > 1]))