SP15561 IITKWPCH - Find Number Of Pair of Friends

Description

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) is not. Find out no of pairs which are friends. (Formally speaking Let us assume the n numbers be 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 Format

T : no of test cases (T >= 1 && T

Output Format

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