Time Limit: 2000/1000 MS (Java/Others)

Memory Limit: 262144/131072 K (Java/Others)

ZCC has got N strings. He is now playing a game with Miss G.. ZCC will pick up two strings among those N strings randomly(A string can't be chosen twice). Each string has the same probability to be chosen. Then ZCC and Miss G. play in turns. Miss G. always plays first. In each turn, the player can choose operation A or B.

Operation A: choose a non-empty string between two strings, and delete a single letter at the end of the string.

Operation B: When two strings are the same and not empty, empty both two strings.

The player who can't choose a valid operation loses the game.

ZCC wants to know what the probability of losing the game(i.e. Miss G. wins the game) is.

Operation A: choose a non-empty string between two strings, and delete a single letter at the end of the string.

Operation B: When two strings are the same and not empty, empty both two strings.

The player who can't choose a valid operation loses the game.

ZCC wants to know what the probability of losing the game(i.e. Miss G. wins the game) is.

The first line contains an integer $T(T\leq 5)$ which denotes the number of test cases.

For each test case, there is an integer $N(2 \leq N\leq 20000)$ in the first line. In the next N lines, there is a single string which only contains lowercase letters. It's guaranteed that the total length of strings will not exceed 200000.

For each test case, there is an integer $N(2 \leq N\leq 20000)$ in the first line. In the next N lines, there is a single string which only contains lowercase letters. It's guaranteed that the total length of strings will not exceed 200000.

提交代码