- Time limit: 2.00 s
- Memory limit: 512 MB
You are given a string of length and a list of words. Your task is to calculate for each prefix of the number of words that can be formed using its letters.
For example, if the prefix is and the words are , , , you can form both and , since there are two 's and one , but not , since there is only one .
Input
The first line contains two integers and : the length of and the words in the list. The second line contains a string of length . Finally, there are lines, each containing a word.
Output
Output integers, where the 'th is the amount of words that can be formed using the letters in the prefix of length of .
Constraints
- the total length of the words is at most
- all letters are lowercase English letters ()
Example
Input:
3 3 aab aa ba bb
Output:
0 1 2
Explanation:
- With letters (one ), you cannot form any words.
- With letters (two 's), you can form , but not or since there are no 's.
- With letters (two 's and one ), you can form both and , but not , since there is only one .