#P1706A. Another String Minimization Problem
Another String Minimization Problem
No submission language available for this problem.
Description
You have a sequence of length , consisting of integers between and . You also have a string , consisting of characters B.
You are going to perform the following operations.
- At the -th () operation, you replace either the -th or the -th character of with A. You can replace the character at any position multiple times through the operations.
Find the lexicographically smallest string you can get after these operations.
A string is lexicographically smaller than a string of the same length if and only if in the first position where and differ, the string has a letter that appears earlier in the alphabet than the corresponding letter in .
The first line contains the number of test cases ().
The first line of each test case contains two integers and () — the length of the sequence and the length of the string respectively.
The second line contains integers () — the sequence .
For each test case, print a string of length — the lexicographically smallest string you can get. Each character of the string should be either capital English letter A or capital English letter B.
Input
The first line contains the number of test cases ().
The first line of each test case contains two integers and () — the length of the sequence and the length of the string respectively.
The second line contains integers () — the sequence .
Output
For each test case, print a string of length — the lexicographically smallest string you can get. Each character of the string should be either capital English letter A or capital English letter B.
Samples
Note
In the first test case, the sequence . One of the possible solutions is the following.
- At the -st operation, you can replace the -st character of with A. After it, becomes ABBBB.
- At the -nd operation, you can replace the -th character of with A (since ). After it, becomes ABBBA.
- At the -rd operation, you can replace the -rd character of with A. After it, becomes ABABA.
- At the -th operation, you can replace the -st character of with A. After it, remains equal to ABABA.
In the second test case, you are going to perform only one operation. You can replace either the -nd character or -th character of with A. You can get strings BABBB and BBBAB after the operation. The string BABBB is the lexicographically smallest among these strings.
In the third test case, the only string you can get is A.
In the fourth test case, you can replace the -st and -nd characters of with A to get AABB.
In the fifth test case, you can replace the -st and -rd characters of with A to get ABABBBB.