Magic Spells
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

One day in the magic world, the young wizard RoundDog was learning the compatibility of spells. After experimenting for a long time, he reached the conclusion that the compatibility of a spell collection can be measured by the number of distinct palindromes that are substrings of all the spells in the collection. He was so excited and planned to write a program to calculate the compatibility of any input spell collection.

However, RoundDog was busy participating the NowWizard Multi-Universe Training this week. He was too struggling during the competition and feels tired now.

Since RoundDog is not in the mood to finish the program now, could you help him?

输入描述:

The first line contains a single integer k , indicating the number of spells in a spell collection.

In the following k lines, each line contains a spell S , which is a string containing only lowercase English letters.

It is guaranteed that the total length of the spells does not exceed .

输出描述:

Output the compatibility of the input spell collection, which is the number of distinct palindromes that are substrings of all the spells in the collection.
示例1

输入

复制
3
abaca
abccaca
acabb

输出

复制
4

说明

In the example, "a", "b", "c", "aca" are the four distinct palindromes that are substrings of all the input spells.