#IITKWPCH. Find Number Of Pair of Friends

Find Number Of Pair of Friends

You are given n numbers. Any two number are called friends if they have some digit common. eg. (11, 12) and (15, 4561) are friends but (33, 556) are not.

Find out the number of pairs which are friends.

(Formally speaking let us suppose the n numbers are stored in array a[]. You have to find out number of i and j pairs such that i < j and a[i] and a[j] are friends.)

Input

T : number of test cases (1 ≤ T ≤ 7) 
For each test case, you will be given two lines, first line will contain n <= 106, then the next line will contain n integers representing a[i] (1 ≤ a[i] ≤ 1018.)

Output

For every test case print a line containing number of such pairs as mentioned in the problem statement.

Example

Input:
4
2
12 13
3
10 12 24
3
5 6 7
4
10 11 211 3

Output: 1 2 0 3

</p>