KOMPICI - Kompići

After successfully solving his math homework from the previous task, Mirko has become bored, so he has made a list of N large integers. On the list there are some pairs of numbers that he likes, and some pairs he doesn’t like. Mirko has named the pairs that he likes pals. Two numbers are pals if they have at least one digit in common (not necessarily in the same position). 

Help Mirko count how many pairs of numbers in his list are pals

Input

The first line of input contains the positive integer N (1 ≤ N ≤ 500 000). Each of the next N lines contains a positive integer from the range [1, 1018], a number from Mirko’s list. No two numbers in the list will be equal.

Output

The first and only line of output must contain the number of pairs that are pals.

Example

Input:
3
4
20
44

Output:
1

Added by:Tadek Dul
Date:2011-11-23
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:C C++ 4.3.2 CPP HASK JAVA PAS-FPC PYTHON
Resource:COCI 2011/2012 2nd round

hide comments
2012-11-29 13:22:55 Erik Lonèarek
@me
3 4 4 4 -> 3
4 34 3 3 4 -> 4
2012-11-05 17:58:26 Erik Lonèarek
What is the output for:
3 4 4 4 and
4 34 3 3 4 ?

Last edit: 2012-11-05 18:13:36
2012-08-15 09:14:38 conioh
nice question..

Last edit: 2012-08-26 06:50:25
2012-07-30 13:51:56 MR. BEAN
very nice question :)
2011-11-27 16:16:53 Aman Kumar
yes how to solve this? can anyone provide some hint....
2011-11-26 19:38:38 skmiiita
how can i approach this problem??
please give me some hint;

Hint: Think Binary

Last edit: 2012-08-03 14:13:50
2011-11-25 09:56:36 Tadek Dul
I rejudged submissions yesterday - it's my first problem added to spoj, and I'm still learning the system. Sorry for this.
2011-11-25 03:01:01 Aman Kumar
got ac yesterday ... shows TLE today !? WTH..!


Last edit: 2011-11-25 03:08:00
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.