There was a power value associated with each soldier of Ram’s troop. It was a known belief that if two soldiers could be paired such that their total power can be divided by 3 perfectly, the pairing becomes ultra-powerful. Ram was curious as to see how many such pairings were possible.
Help Ram find out the number of pairings(not necessarily unique) possible from his troop.

INPUT:
An integer T (1 ≤ T ≤ 1000) : number of testcases
Each test case is represented by a number N(1 ≤ N ≤ 100) denoting the number of soldiers followed by an unordered list of N values representing the soldier’s power P(1 ≤ P ≤ 10000).

OUTPUT:
For each test case T, output the value of number of possible pairs from the given list such that the sum of the values in each pair is a multiple of 3.

SAMPLE INPUT
3
5
3 6 7 2 9
4
2 1 3 4
3
9 9 9

SAMPLE OUTPUT
4
2
3

Explanation

In the first test case, the groups are (3,6),(3,9),(9,6),(7,2).

In the second test case, the groups are (2,1),(2,4)

In the third test case, the groups are (9,9),(9,9),(9,9))

Difficulty: EASY

Solutions:
t=int(input())
ti=0
while ti<t:
	n=int(input())
	l=list(map(int,input().split()))
	c=0
	for i in range(len(l)):
		for j in range(i+1,len(l)):
			if (l[i]+l[j])%3==0:
				c+=1
	print(c)
	ti+=1


tc = eval(input())
for etc in range(tc):
	no = eval(input())
	numbers = input()
	numbers = numbers.split()
	for i in range(no):
		numbers[i] = int(numbers[i])
	count = 0
	for i in range(no):
		for j in range(i+1,no):
			if((numbers[i] + numbers[j])%3 ==0):
				count+=1
	print(count)


noOfTestCases = int(input())

def count(inos):
	outerStart = 0
	count = 0
	maxLimit = len(inos)
	while(outerStart < maxLimit):
		innerStart = outerStart + 1
		while(innerStart < maxLimit):
			if((inos[innerStart] + inos[outerStart]) % 3 == 0):
				count += 1
			innerStart += 1
		outerStart += 1	

	print(count)

for caseNo in range(1, noOfTestCases + 1):
	total  = int(input())
	nos = input().split(" ")
	inos = []
	for n in nos:
		inos.append(int(n))	
	count(inos)


noOfTestCases = int(input())

def count(inos):
	outerStart = 0
	count = 0
	maxLimit = len(inos)
	while(outerStart < maxLimit):
		innerStart = outerStart + 1
		while(innerStart < maxLimit):
			if((inos[innerStart] + inos[outerStart]) % 3 == 0):
				count += 1
			innerStart += 1
		outerStart += 1	

	print(count)

for caseNo in range(1, noOfTestCases + 1):
	total  = int(input())
	nos = input().split(" ")
	inos = []
	for n in nos:
		inos.append(int(n))	
	count(inos)


t=eval(input())
for x in range(0,t):
	n=eval(input())
	arr=input().split()
	arr=list(map(int,arr))
	c=0
	for j in range(0,len(arr)-1):
		for k in range(j+1,len(arr)):
			if((arr[j]+arr[k])%3==0):
				c=c+1
	print(c)