eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Match me if you can

Match me if you can

After watching the movie "Catch me if you can" professor Mahammad became very confident about creating a new problem for his programmers. As some procedures in his research heavily depend on string matching, now, he wants to check his beginner programmers' skills in this topic as well. His task is very simple. Professor gives you a random string and several queries. For each of the query string, you have to count the number of its occurrences in the string provided by professor.

Input

First line of the input section contains two positive integers N (N ≤ 3000) and Q, which define the length of professor's string and the number of queries, respectively. Second line contains professor's string having length N. The following Q lines contain a query string having nonzero length. The sum of the length of query strings does not exceed 500000.

Output

For each of the queries, output the number of the desired count of the occurences.

Лимит времени 1 секунда
Лимит использования памяти 1024 MiB
Входные данные #1
7 5
acababa
a
bb
caba
aba
karp
Выходные данные #1
4
0
1
2
0
Автор Mahmud Allahverdiyev
Источник EJOI Team Selection - 2018