String concatenation

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

Input

Input consists of several cases, each with \ell and mm, followed by mm different words. Assume that \ell is between 1 and 101810^{18}, that mm 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 109+910^9 + 9.

Problem information

Author: Pol Mauri

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

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