How many different words of length exactly can you build by concatening given words? You can use any word as many times as you wish.
Input consists of several cases, each with and , followed by different words. Assume that is between 1 and , that is at least 1, that the words only have lowercase letters, and that the sum of their lenghts is at most 50.
For every case, print the result modulo .
Author: Pol Mauri
Generation: 2026-01-25T11:11:19.895Z
© Jutge.org, 2006–2026.
https://jutge.org