Under construction

Still being built. Things may change

Consistent Occurrences

Time limit4sMemory limit512 MB

Summary
Given a string s and many query strings, for each query find the largest set of non-overlapping occurrences of that query string in s.
Level

Hard8 of 10

Topics
String, String matching, Greedy, Sorting
Solved
No attempts yet

Problem

A consistent set of occurrences of string tt in string ss is a set of occurrences of tt in ss such that no two occurrences intersect. In other words, no character position in ss belongs to two different occurrences.

You are given a string ss consisting of nn lowercase English letters, and mm queries. Each query contains a single string t_it\_i.

For each query, print the maximum size of a consistent set of occurrences of tt in ss.

Input

The first line contains two space-separated integers nn and mm: the length of string ss and the number of queries (1≤n≤1051 \le n \le 10^{5}, 1≤m≤1051 \le m \le 10^{5}).

The second line contains the string ss consisting of nn lowercase English letters.

Each of the next mm lines contains a single string t_it\_i consisting of lowercase English letters: the ii-th query (1≤∣t_i∣≤n1 \le |t\_i| \le n, where ∣t_i∣|t\_i| is the length of the string t_it\_i).

It is guaranteed that the total length of all t_it\_i does not exceed 10510^{5} characters.

Output

For each query ii, print one integer on a separate line: the maximum size of a consistent set of occurrences of t_it\_i in ss.

Examples1

  1. Example 1

    Input
    6 4
    aaaaaa
    a
    aa
    aaa
    aaaa
    
    Expected output
    6
    3
    2
    1