#C1212. K-th Smallest Character in a String

    ID: 41512 Type: Default 1000ms 256MiB

K-th Smallest Character in a String

K-th Smallest Character in a String

Given a string s of length n consisting of lowercase English letters, you need to answer q queries. In each query, you are given an integer k and you must output the k-th smallest character in the sorted order of the characters of s.

The lexicographical order is defined as the standard dictionary order. For example, the sorted order of the string "banana" is "aaabnn" so the 1st smallest character is 'a', the 3rd smallest is 'a', and the 6th smallest is 'n'.

Input Format: The first line of input contains two integers n and q. The second line contains the string s. The following q lines each contain one integer k. All queries are guaranteed to have valid k values.

Output Format: For each query, output the corresponding k-th smallest character on a separate line.

inputFormat

The input is given from stdin and consists of several lines:

  1. The first line contains two integers n and q separated by a space, where n is the length of the string and q is the number of queries.
  2. The second line contains the string s consisting of lowercase English letters.
  3. Each of the next q lines contains a single integer k representing the query.

outputFormat

For each query, output the k-th smallest character (based on lexicographical order) on a new line. The output should be sent to stdout.## sample

6 3
banana
1
3
6
a

a n

</p>