Denny just learned the sorting method in school.
Sorting once is too easy for him, so the teacher asked a question that needs to be sorted twice to test him.
In this question, you will get a string V, and N strings of length 6, you need to sort the strings internally according to the order of the string V, and then sort the N strings in dictionary order. All strings contain only lower-case letters.
For example:
N = 2
S1 = abcabc, S2 = ababab
V = cbadefghijklmnopqrstuvwxyz
Internally sorted string: S1 = ccbbaa, S2 = bbbaaa
The sorted string after sorting: bbbaaa ccbbaa
The first line contains a integer N, the number of strings you need to sort
The second line contains a string V
The following line contains N strings S1 ~ SN
testcase:
(3/6) 1 <= N <= 100, V = abcdefghijklmnopqrstuvwxyz
(3/6) 1 <= N <= 100, V = the permutation of a~z
The Output contains only one line, the sorted string after sorting.
note: remember to add a '\n' in the end of output