Codeforces Round 798 (Div. 2)
A
Lex String
Codeforces
800
原题
←B →
翻译中…

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

翻译中…

Recently, Kuznecov has found two strings, $a$ and $b$, of lengths $n$ and $m$ respectively. They consist of lowercase English letters and no character is contained in both strings.

翻译中…

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

翻译中…
  • Choose any character from the string $a$, remove it from $a$, and add it to the end of $c$.
  • Choose any character from the string $b$, remove it from $b$, and add it to the end of $c$.
翻译中…

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

翻译中…

A string $x$ is lexicographically smaller than a string $y$ if and only if one of the following holds:

翻译中…
  • $x$ is a prefix of $y$, but $x \neq y$;
  • in the first position where $x$ and $y$ differ, the string $x$ has a letter that appears earlier in the alphabet than the corresponding letter in $y$.
翻译中…

Input

翻译中…

There are several test cases in the input data. The first line contains a single integer $t$ ($1 \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 $n$, $m$, and $k$ ($1\leq n,m,k \leq 100$) — parameters from the statement.

翻译中…

The second line of each test case contains the string $a$ of length $n$.

翻译中…

The third line of each test case contains the string $b$ of length $m$.

翻译中…

The strings contain only lowercase English letters. It is guaranteed that no symbol appears in $a$ and $b$ simultaneously.

翻译中…

Output

翻译中…

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

翻译中…

Note

翻译中…

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

翻译中…

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

翻译中…

样例

Input #1
3
6 4 2
aaaaaa
bbbb
5 9 3
caaca
bedededeb
7 7 1
noskill
wxhtzdy
Output #1
aabaabaa
aaabbcc
dihktlwlxnyoz
InputCopy OutputCopy
题目信息
题号
1689A
时间限制
1 s
内存限制
256 MB
标签
暴力
贪心
模拟
排序
双指针

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。