We call a pair of non-negative integers suitable if there is at least one common digit in their decimal notation (not necessarily in the same digit). Let there be given n non-negative numbers a[1]
, a[2]
, ..., a[n]
. Consider all possible pairs (a[i]
, a[j]
) (1 ≤ i < j ≤ n).
Write a program that will determine the number of all suitable pairs.
The first line contains positive integer n, not greater than 10^6
. Second line contains n nonnegative integers, not greater 999.
Print the number of suitable pairs.