atcoder#RELAY2G. Coinage
Coinage
Score : points
Problem Statement
You are given two strings and consisting of lowercase English letters and an integer .
We will consider generating a string of length by concatenating one or more copies of and . Here, it is allowed to use the same string more than once.
For example, when at
code
and the strings atatat
atcode
and codeat
can be generated.
Among the strings that can be generated in this way, find the lexicographically smallest one. In the cases given as input, it is always possible to generate a string of length .
Constraints
- and consist of lowercase English letters.
- It is possible to generate a string of length in the way described in Problem Statement.
Input
Input is given from Standard Input in the following format:
Output
Print the lexicographically smallest string among the ones that can be generated in the way described in Problem Statement.
6
at
code
atatat
This input corresponds to the example shown in Problem Statement.
8
coding
festival
festival
It is possible that either or cannot be used at all in generating a string of length .
8
same
same
samesame
It is also possible that .
10
coin
age
ageagecoin