


First-line contains ‘T’, denoting the number of Test cases.
For each Test case:
The first line contains an integer ‘N’, denoting the length of the String.
The following line contains the string ‘S’ of the length ‘N’.
The following line contains an integer ‘M’, denoting the number of pairs.
The following ‘M’ line contains two space-separated integers, denoting the pair of indices.
For each test case, print the lexicographically smallest string that you can make after rearranging the string ‘S’.
1 <= ‘T’ <= 10
1 <= ‘N’ <= 10^5
1 <= ‘M’ <= 10^5
1 <= Pair[i][0], Pair[i][1] <= ‘N’ i ∈ (1,M)
Note-sum of ‘N’ and ‘M’ over all test cases does not exceed 10^5, respectively.
Time Limit: 1 sec
We then want to look at the characters associated with those indices in the connected components. Sort these characters and place them in ascending order in the index. We will do this for all the connected components and then assign them back to a string and print the string.
Algorithm: