Time Limit : sec, Memory Limit : KB
English / Japanese  

Slates

Numerous stone slates have been discovered in the ruins of the ancient nation of Iwashiro. Researchers have found that each slate has a single word inscribed on it. However, due to weathering over the years, some of the slates seem to be difficult to decipher for the following reasons.

  • In some cases, only one of the letters of the word on the slate is covered with moss, making it impossible to figure out the word.
  • The left side of the slate is missing (chipped), and there may have been some text written there (we cannot grasp more than or equal to 0 letters on the left side of the slate).
  • The right side of the slate is missing (chipped), and there may have been some text written there (we cannot grasp more than or equat to 0 letters on the right side of the slate).

There is at most one place where moss grows on the slate. In addition, although moss may grow on the chipped slate, both sides of the slate are not chipped at the same time.

Researchers have a dictionary of words known from surveys prior to the discovery of the slates. However, when guessing the original word from a slate with moss and chips due to the effects of weathering, it is not immediately clear how many words in the dictionary apply.

Write a program to count how many words in the given dictionary might fit for given a slate.

Input

The input is given in the following format.

N M
word1
word2
:
wordN
slate1
slate2
:
slateM

In the first line, the number of words in the dictionary N (1 ≤ N ≤ 50000), the number of slates M (1 ≤ M ≤ 50000) are given. The following N line gives the words word i . A word is a character string with a length of 1 or more and 200 or less, including only lowercase letters. Note that the N words are all different. The following M lines give the string slate i that represents the information for each slate. slate i is a character string with a length of 1 or more and 200 or less, including lowercase letters, "?", And "*". ? represents a moss-covered character. At most one ? appears in one string. If the string starts with *, it means that the left side of the slate is missing. If the string ends with *, it indicates that the right side of the slate is missing. * does not appear except at the beginning or end of the string, and does not appear on both sides at the same time. A string with only one * is never given.

The total number of characters in the string given in the input does not exceed 3000000.

Output

For each slate, output the number of words on a single line.

Sample Input 1

5 4
aloe
apple
apricot
cactus
cat
apple
ap*
*e
ca?*

Sample Output 1

1
2
2
2