# 描述

Liyuan lives in a old apartment. One day, he suddenly found that there was a wireless network in the building. Liyuan did not know the password of the network, but he got some important information from his neighbor. He knew the password consists only of lowercase letters a-z, and he knew the length of the password. Furthermore, he got a magic word set, and his neighbor told him that the password included at least k words of the magic word set (the k words in the password possibly overlapping).

For instance, say that you know that the password is $3$ characters long, and the magic word set includes she and he. Then the possible password is only she.

Liyuan wants to know whether the information is enough to reduce the number of possible passwords. To answer this, please help him write a program that determines the number of possible passwords.

## Input

There will be several data sets. Each data set will begin with a line with three integers $n$ $m$ $k$. $n$ is the length of the password $(1≤n≤25)$, $m$ is the number of the words in the magic word set$(0≤m≤10)$, and the number $k$ denotes that the password included at least $k$ words of the magic set. This is followed by $m$ lines, each containing a word of the magic set, each word consists of between $1$ and $10$ lowercase letters a-z. End of input will be marked by a line with $n=0$ $m=0$ $k=0$, which should not be processed.

## Output

For each test case, please output the number of possible passwords MOD $20090717$.

# 思路

• 题意：长度为$n$的字符串包含至少$k$个串的情况有多少种。
• 模式串集合很少，可以考虑状态压缩。
• 在AC自动机上DP即可。状态表示$dp[i][j][mask]$表示长度为$i$的串，在自动机的$j$结点，包含模式串集合为$mask$的组合数。$dp[0][0][0] = 1$。
• 这样最后的答案就是$\sum dp[n][j][mask]$(其中$mask$的二进制表示中$1$的个数大于等于$k$)
• 一个数的二进制有多少个$1$可以用gcc的内置函数__builtin_popcount()

0%