1487. Conspicuousness

One day, Mikasa found a password consisting of numbers from 191-9. She wants to know how conspicuous this password is to Allen. Allen has a visual threshold of kk, and only the number whose length is not less than kkk can be noticed by him.

We define f(x,S)f(x,S) as the number of occurrences of the number xx in the password SS.

Then we define the conspicuousness g(S)g(S) of a password SS:

g(S)=maxxS, xkf(x,S) g(S) = \max_{x \in S, \ |x|≥k}{f(x,S)}

Noticed: xSx \in S means number xx is a subnumber of the password SS. For example, 23123423 \in 1234 is true and 24123424 \in 1234 is not.

Since Mikasa does not know the visual threshold kk, please help calculate the conspicuousness g(S)g(S) under the qq kinds of situations.

输入

The first line contains two positive integers n(1n3e5)n(1\leq n\le3e5) and q(1q3e5)q(1\leq q\le3e5), indicating the length of the password and the number of situations;

The second line contains a number with a length of nn, which represents the password discovered by Mikasa;

In the next qq line, each line has a positive integer k(1kn)k(1\leq k \le n), which represents the visual threshold of Allen.

输出

The output should contain qq lines, each representing the conspicuousness g(S)g(S) in different situations.

样例

标准输入 复制文本
3 2
131
1
2
标准输出 复制文本
2
1
标准输入 复制文本
3 2
666
3
2
标准输出 复制文本
1
2

来源

2021 GDCPC 广东省大学生程序设计竞赛

登录以提交代码。
单点时限 2 秒
内存限制 512 MB
提交 6
通过 2