## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

# [Solution] Another String Minimization Problem Codeforces Solution

A. Another String Minimization Problem
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You have a sequence ${a}_{1},{a}_{2},\dots ,{a}_{n}$ of length $n$, consisting of integers between $1$ and $m$. You also have a string $s$, consisting of $m$ characters B.

You are going to perform the following $n$ operations.

• At the $i$-th ($1\le i\le n$) operation, you replace either the ${a}_{i}$-th or the $\left(m+1-{a}_{i}\right)$-th character of $s$ 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 $x$ is lexicographically smaller than a string $y$ of the same length if and only if in the first

position where $x$ and $y$ differ, the string $x$ has a letter that appears earlier in the alphabet than the corresponding letter in $y$.

Input

The first line contains the number of test cases $t$ ($1\le t\le 2000$).

Another String Minimization Problem Codeforces Solution

Making Towers Codeforces Solution

Qpwoeirut And The City Codeforces Solution

Chopping Carrots (Easy Version) Codeforces Solution

Chopping Carrots (Hard Version) Codeforces Solution

The first line of each test case contains two integers $n$ and $m$ ($1\le n,m\le 50$) — the length of the sequence $a$ and the length of the string $s$ respectively.

The second line contains $n$ integers ${a}_{1},{a}_{2},\dots ,{a}_{n}$ ($1\le {a}_{i}\le m$) — the sequence $a$.

Output

For each test case, print a string of length $m$ — the lexicographically smallest string you can get. Each character of the string should be either capital English letter A or capital English letter B.