Problem C: 字符串的前缀

Memory Limit:512 MB Time Limit:5.000 S
Judge Style:Text Compare Creator:
Submit:74 Solved:7

Description

现在给定n 个字符串 s1s2...sn和 q次询问,每次询问给定一个字符串 s ,请回答 s1~sn 中有多少个字符串的前缀是s。

一个字符串 t 是 s 的前缀,当且仅当从 s 的末尾删去若干个(可以为 0 个)连续的字符后与 t 相同。
输入的字符串对字母的大小写敏感。例如,字符串 Apple 和字符串 apple 不同。

Input

输入第一行是两个整数,分别表示字典串的个数  n 和询问的个数q。 

接下来 n 行,每行一个字符串,表示一个字典串。

接下来 q 行,每行一个字符串,表示一次询问。

Output

按照输入询问的顺序,依次输出一行一个整数表示答案。

Sample Input Copy

5 3
apple
Nothingfornothing
Nothingisimpossible
underestimateapple
Redapple
apple
Nothing
nothing

Sample Output Copy

1
2
0

HINT

1≤n,q≤2*10^6。 输入的字符串只含大小写字母和数字,且不含空串。