E. Double-Colored Papers
time limit per test
3 seconds
memory limit per test
1024 mebibytes
input
standard input
output
standard output

In your factory, you are making two kinds of colored paper, one colored red, and the other colored blue.

Each red-colored paper has a string $$$S$$$ written on it: it is made of $$$|S|$$$ unit squares in a row, and $$$S_i$$$ is written on the $$$i$$$-th square from the left.

Each blue-colored paper has a string $$$T$$$ written on it: it is made of $$$|T|$$$ unit squares in a row, and $$$T_i$$$ is written on the $$$i$$$-th square from the left.

You plan to make a new kind of paper called double-colored paper out of red and blue paper. To do so, you will cut a piece of red paper to leave a continuous part with positive integer length, then do the same with a piece of blue paper. After that, you will glue the end of the red piece to the start of the blue piece.

For example, suppose $$$S$$$ is abcde and $$$T$$$ is fghij. You can make a double-colored paper with string $$${\color{red}{\underline{\texttt{bcd}}}}{\color{blue}{\texttt{fg}}}$$$ or $$${\color{red}{\underline{\texttt{abc}}}}{\color{blue}{\texttt{ij}}}$$$ written on it. However, you cannot make a double-colored paper with string $$${\color{red}{\underline{\texttt{acd}}}}{\color{blue}{\texttt{ghij}}}$$$ or $$${\color{blue}{\texttt{fghij}}}$$$ written on it. (Here the underlined string denotes a red piece, and the rest denotes a blue piece.) Two pieces of double-colored paper are considered the same if they have the same red string and the same blue string written on them.

Among all different pieces of double-colored paper that can be made, you want to know the one with the lexicographically $$$K$$$-th smallest string written on it. Note that there may be papers with the same strings written on them, but with different lengths of red paper: in this case, you may order them arbitrarily.

Input

The first line contains the string $$$S$$$.

The second line contains the string $$$T$$$.

The third line contains the integer $$$K$$$.

  • $$$1 \le | S | \le 75\,000$$$
  • $$$1 \le | T | \le 75\,000$$$
  • $$$S$$$ and $$$T$$$ consist of lowercase English letters
  • $$$1 \le K \le 8 \cdot 10^{18}$$$
Output

If the total number of possible double-colored papers is strictly less than $$$K$$$, output $$$-1$$$.

Otherwise, output the lexicographically $$$K$$$-th smallest string of all possible double-colored papers that can be made.

Example
Input
tww
wtw
21
Output
wwtw