You are given a string of length
consisting of lowercase English letters and a non-decreasing array
.
A set of non-empty strings is called good if and only if:
For a good set , denote the value of
as
, where
is the length of string
.
For a string and some positive integer
, define
as the maximum value among all good sets
that satisfies the following conditions:
You need to answer queries. For each of them, you are given two values
(
), and you need to find out
, where
denotes the prefix with
letters of
.
The input consists of multiple test cases.
The first line consists of a single integer
- the number of test cases. Then
test cases descriptions follow.
The first line of every case consists of two integers
(
) - the length of the string
and the number of queries.
The second line contains the string
.
The third line contains
positive integers
(
). It is guaranteed that
.
For the next
lines, each line contains two positive integers
(
), describing a query.
It is guaranteed that
.
For each query, print an integer indicating your answer.