for _ in range(int(input())): s=input() p=input() sorted_string = ‘’.join(sorted(s)) print(sorted_string)