


Both the strings have only lowercase English alphabets.
There may be more than one correct solution, you have to return any one of the possible solutions.
The first line of input contains an integer ‘T’ denoting the number of test cases.
Then the T test cases follow.
The first line of each test case contains the string X.
The second line of each test case contains the string Y.
For each test case, print the string X after converting string X in the specific order with respect to string Y.
The output of each test case is printed in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= |X| <= 10000
1 <= |Y| <= 26
where ‘T’ is the number of test cases, |X| is the length of the first string and |Y| is the length of the second string.
Time Limit: 1 sec
The idea is to follow the order in which the characters occur in string Y. We have to run two nested loops on strings Y and X respectively and if Yi is the same as Xj then pick this character and add it to the answer string.
For the remaining characters of X that are not in the string Y, we have to just add those characters in our answer string. To find those remaining characters we can create a vector of visited characters or a hash set.