#P7552. [COCI 2020/2021 #6] Anagramistica
[COCI 2020/2021 #6] Anagramistica
Description
Biljana likes making word puzzles.
If one word can be obtained from another word by rearranging its letters, then the two words are called “similar”.
Now, she has words. She wants to select some words such that there are exactly pairs of “similar” words among them. Please help her compute the number of feasible ways, modulo .
Input Format
The first line contains two integers and .
The next lines each contain a string, representing a word.
Output Format
Output one integer on a single line, representing the number of feasible ways, modulo .
3 1
ovo
ono
voo
2
5 2
trava
vatra
vrata
leo
ole
3
6 3
mali
lima
imal
je
sve
ej
6
Hint
Explanation for Sample 1
The selections that contain exactly one pair of “similar” words are ovo, ono, voo and ovo, voo.
Constraints
This problem uses bundled testdata.
| Subtask | Score | Constraints |
|---|---|---|
| No additional constraints. |
For of the testdata, , , the length of each word is at most , and it contains only lowercase letters.
Notes
The score settings of this problem follow the original COCI problem, with full score .
This problem is translated from COCI2020-2021 CONTEST #6 T3 Anagramistica。
Translated by ChatGPT 5
京公网安备 11011102002149号