#1066
Unrated
RAZBIBRIGA
시간 제한
1s
메모리 제한
32MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

Author: Frane Kurtović

Mirko has already solved all crosswords available in daily newspapers, and he is too intimidated by ACTA to download new ones from the Internet. Now he has asked Frane to challenge him with a programming problem. Frane has eagerly responded with a brand new task, and was kind enough not to lock the task under copyright protection, so you are allowed to attempt it too! Four words with equal lengths can be put together in a square such that two words mark horizontal edges, while the other two mark vertical edges. Horizontal words are read left to right, and vertical ones from top to bottom. Corner letters are shared by the two neighbouring edges. The figure below shows one possible square created from words “HLAD”, “NIVA”, “HSIN”, “DEDA”.

Your task is, given a list of equal-length words, to compute the number of different squares that can be put together from a subset of these words. You are not allowed to repeat a word in the same square. Two squares are different if they differ in at least one character.

입력

The first line of input contains the positive integer N (4 ≤ N ≤ 100 000), the number of words in the list. Each of the next N lines contains a single word consisting only of uppercase English letters. Each word will contain at most 10 characters. All words will be distinct and have equal length.

출력

The first and only line of output must contain the required number of distinct squares. Note: Test data will ensure that the solution fits in a 64-bit integer data type (int64 in Pascal, long long in C/C++).

예제 입력 1

4
NIVA
HLAD
HSIN
DEDA

예제 출력 1

2

예제 입력 2

6
BAKA
BARA
BALC
CALC
ARHC
BLIC

예제 출력 2

8
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.