#1241
Unrated
OOP
시간 제한
2s
메모리 제한
512MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

2 seconds, 512 MB, 140 points Little Matej is solving an OOP (Object-oriented programming) laboratory exercise and he’s having trouble with solving one subtask. He is given a set that contains N words. He is also given Q queries where each query is one pattern. A pattern consists of a single character “” and lowercase letters of the English alphabet. For example, “”, “kulto”, “ana”. A pattern is said to cover a word if such an array of letters (which can be empty) exists that, when replacing the character ‘*’, the pattern and the word become completely identical. It is necessary to output how many words each pattern covers.

입력

The first line of input contains two integers N and Q (1 ⩽N, Q ⩽100 000). Each of the following N lines contains a word that consists of lowercase letters of the English alphabet. Each of the following Q lines contains a pattern for which you need to output how many words from the first set it covers. The total number of characters will be less than 3 000 000. SCORING In test cases worth 40% of total points, it will additionally hold 1 ⩽N, Q ⩽1000.

출력

Output Q lines, the kth line containing the number of words that the kth pattern covers.

예제 입력 1

3 3
aaa
abc
aba
a*a
aaa*
*aaa

예제 출력 1

2
1
1

예제 입력 2

5 3
eedecc
ebdecb
eaba
ebcddc
eb
e*
*dca
e*c

예제 출력 2

5
0
2
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.