아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Trio

시간 제한2초메모리 제한1024 MB

요약
네 자리 수 집합에서 각 자릿수가 모두 같거나 모두 다른 세 원소 부분집합의 개수를 센다.
난이도

보통10점 중 5점

유형
조합론, 해시맵, 완전 탐색
정답자
아직 제출이 없습니다

문제

Let AA be any set of nn natural numbers whose decimal representations consist of exactly four digits without 00 in any decimal place.

A trio is a set of three numbers a,b,c\\{a, b, c\\} chosen from AA such that the following conditions are fulfilled simultaneously:

  • The ones decimals of three numbers aa, bb, cc are either all equal or all distinct.
  • The tens decimals of three numbers aa, bb, cc are either all equal or all distinct.
  • The hundreds decimals of three numbers aa, bb, cc are either all equal or all distinct.
  • The thousands decimals of three numbers aa, bb, cc are either all equal or all distinct.

For examples, 1425,1113,1354\\{1425, 1113, 1354\\} is a trio if the three numbers are members of AA because the ones decimals of the three numbers are all distinct, their tens decimals are all distinct, their hundreds decimals are all distinct, and their thousands decimals are all equal. The set 1425,1113,5436\\{1425, 1113, 5436\\}, however, is not a trio, even if AA contains those three numbers.

Given a set AA as input, write a program that computes and prints out the number of different trios.

입력

Your program is to read from standard input. The input starts with a line consisting of a single integer nn (1≤n≤2,0001 ≤ n ≤ 2,000) that represents the number of members in AA. Each of the following nn lines consists of a positive integer in decimal form that consists of exactly four digits without 00 in any decimal place. These nn numbers are supposed to be all distinct and the members of the input set AA.

출력

Your program is to write to standard output. Print exactly one line. The line should consists of a single integer that represents the number of different trios for the input set AA.

예제2

  1. 예제 1

    입력
    6
    1234
    1235
    1244
    1233
    7133
    8133
    
    예상 출력
    1
    
  2. 예제 2

    입력
    9
    1234
    5678
    9123
    4567
    8912
    3456
    7891
    2345
    6789
    
    예상 출력
    84