P2908 [USACO08OPEN] Word Power S

Description

Farmer John wants to evaluate the quality of the names of his $N (1 \le N \le 1000)$ cows. Each name is a string with no more than 1000 characters, all of which are non-blank. He has created a set of $M (1 \le M \le 100)$ 'good' strings (no longer than 30 characters and fully non-blank). If the sequence letters of a cow's name contains the letters of a 'good' string in the correct order as a subsequence (i.e., not necessarily all next to each other), the cow's name gets 1 quality point. All strings is case-insensitive, i.e., capital letters and lower case letters are considered equivalent. For example, the name $\texttt{Bessie}$ contains the letters of $\texttt{Be}$, $\texttt{sI}$, $\texttt{EE}$, and $\text{Es}$ in the correct order, but not $\texttt{is}$ or $\texttt{eB}$. Help Farmer John determine the number of quality points in each of his cow's names.

Input Format

* Line $1$: Two space-separated integers: $N$ and $M$. * Lines $2 \sim N+1$: Line $i+1$ contains a string that is the name of the ith cow. * Lines $N+2 \sim N+M+1$: Line $N+i+1$ contains the ith good string.

Output Format

* Lines $1 \sim N+1$: Line $i+1$ contains the number of quality points of the ith name.

Explanation/Hint

There are 5 cows, and their names are $\texttt{Bessie}$, $\texttt{Jonathan}$, $\texttt{Montgomery}$, $\texttt{Alicia}$, and $\texttt{Angola}$. The 3 good strings are $\texttt{se}$, $\texttt{nGo}$, and $\texttt{Ont}$. $\texttt{Bessie}$ contains $\texttt{se}$, $\texttt{Jonathan}$ contains $\texttt{Ont}$, $\texttt{Montgomery}$ contains both $\texttt{nGo}$ and $\texttt{Ont}$, $\texttt{Alicia}$ contains none of the good strings, and $\texttt{Angola}$ contains $\texttt{nGo}$.