Two integers are friends if they contain at least one common decimal digit. The common digit does not have to appear in the same position.
Given N distinct positive integers, count the number of pairs of integers that are friends. A pair consists of two different input integers, and pairs that differ only by order are counted once.
The first line contains the number of integers N. (1 <= N <= 1,000,000)
Each of the next N lines contains one positive integer between 1 and 10^18, inclusive. No integer appears more than once.
Print the number of pairs of integers that are friends.