Dongil came up with a game he can play by himself.
The game starts from one string of N lowercase letters.
Dongil may swap any two letters of the string. He may repeat this operation as many times as he likes, zero times included.
The goal is to build the lexicographically smallest string.
After a few rounds the game felt too easy, so Dongil added one more rule. For every position of the finished string he decides in advance which letters may sit there, like this.
The rule applies only to the final string. A string that appears in the middle of the game does not have to obey it.
The rule made the game much harder. Help Dongil and find the lexicographically smallest string he can build while obeying the rule.
The first line has the number of test cases T. (1≤T≤100)
The first line of each test case has the starting string S, which consists of N lowercase letters. (1≤N≤100)
The next N lines each have a string Ci. Ci consists of Li letters and lists the letters allowed at position i of the result. (1≤Li≤5)
Every letter that appears in Ci appears at least once in the starting string S.
For each test case print, on its own line, the lexicographically smallest string that obeys the rule. If no string obeys the rule, print NO SOLUTION.