String concatenation

How many different words of length exactly ℓ can you build by
concatening m given words? You can use any word as many times as you
wish.

Input

Input consists of several cases, each with ℓ and m, followed by m
different words. Assume that ℓ is between 1 and 10¹⁸, that m is at least
1, that the words only have lowercase letters, and that the sum of their
lenghts is at most 50.

Output

For every case, print the result modulo 10⁹ + 9.

Problem information

Author: Pol Mauri

Generation: 2026-01-25T11:11:19.895Z

© Jutge.org, 2006–2026.
https://jutge.org
