Subsequences

아직 제출이 없습니다시간 제한5초메모리 제한512 MB

문제

In the Datastring Research Corporation, the string ss is called good, if it has even number of distinct subsequences.

The string tt is called a subsequence of the string ss, if it can be derived from ss by crossing out a certain set of symbols. The string ss and the empty string are also considered to be subsequences of ss. In a string of the length ll, there is a total of 2l2^l subsequences, however, some of them may coincide. For instance, a three-letter string abbabb has only 6 distinct subsequences: empty, aa, bb, abab, bbbb, abbabb.

The string ss was lying on the String Researcher's desk, and he was trying to figure out whether it was a good one. He did realize that counting the number of distinct subsequences is a tedious task, so, instead of tackling the task right away, he went on a coffee break --- with donuts.

Upon his return, the String Researcher discovered that someone had made an N1N-1 cuts in the string ss, and it fell apart into NN non-empty substrings s_1,s_2,,s_Ns\_1, s\_2, \dots, s\_N scattered all over the table. And he absolutely does not remember the initial string ss. However, he is curious about how many permutations p=(p_1,,p_N)p = (p\_1, \dots, p\_N) exist, such that the recovered string s_p_1s_p_2s_p_Ns\_{p\_1}s\_{p\_2}\dots s\_{p\_N} is good. Note that there is a total of N!N! permutations (the factorial of NN), and all these permutations are considered different, even if some of the substrings s_is\_i match.

입력

The first line of the input file contains a single integer NN --- the number of substrings (2N202 \leq N \leq 20). The iith of the following NN lines contains the substring s_is\_i.

All of the s_is\_i strings  are non-empty and consist exclusively of lower-case Latin letters. It is guaranteed that the sum of lengths of all the lines s_is\_i does not exceed 10510^5.

출력

In the only line of the output file, print a single integer number: the number of permutations such that the concatenation of the strings s_is\_i in the order of permutation is a good one.

힌트

The string a+a+baaa + a + baa has 14 subsequences, the string a+baa+aa + baa + a has 13 subsequences, and the string baa+a+abaa + a + a has 10 subsequences. Each of these lines can be obtained with the aid of only two permutations, since there are two occurrences of the substring aa.