CF1689A.Lex String

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Lex String

Kuznecov likes art, poetry, and music. And strings consisting of lowercase English letters.

Recently, Kuznecov has found two strings, aa and bb, of lengths nn and mm respectively. They consist of lowercase English letters and no character is contained in both strings.

Let another string cc be initially empty. Kuznecov can do the following two types of operations:

  • Choose any character from the string aa, remove it from aa, and add it to the end of cc.
  • Choose any character from the string bb, remove it from bb, and add it to the end of cc.

But, he can not do more than kk operations of the same type in a row. He must perform operations until either aa or bb becomes empty. What is the lexicographically smallest possible value of cc after he finishes?

A string xx is lexicographically smaller than a string yy if and only if one of the following holds:

  • xx is a prefix of yy, but xyx \neq y;
  • in the first position where xx and yy differ, the string xx has a letter that appears earlier in the alphabet than the corresponding letter in yy.

Input

There are several test cases in the input data. The first line contains a single integer tt (1t1001 \leq t \leq 100) — the number of test cases. This is followed by the test cases description.

The first line of each test case contains three integers nn, mm, and kk (1n,m,k1001\leq n,m,k \leq 100) — parameters from the statement.

The second line of each test case contains the string aa of length nn.

The third line of each test case contains the string bb of length mm.

The strings contain only lowercase English letters. It is guaranteed that no symbol appears in aa and bb simultaneously.

Output

In each test case, output a single string cc — the answer to the problem.

Note

In the first test case, it is optimal to take two 'a's from the string aa and add them to the string cc. Then it is forbidden to take more characters from aa, hence one character 'b' from the string bb has to be taken. Following that logic, we end up with cc being 'aabaabaa' when string aa is emptied.

In the second test case it is optimal to take as many 'a's from string aa as possible, then take as many 'b's as possible from string bb. In the end, we take two 'c's from the string aa emptying it.

Samples

3
6 4 2
aaaaaa
bbbb
5 9 3
caaca
bedededeb
7 7 1
noskill
wxhtzdy
aabaabaa
aaabbcc
dihktlwlxnyoz

在线编程 IDE

建议全屏模式获得最佳体验