atcoder#ABC268D. [ABC268D] Unique Username
[ABC268D] Unique Username
Score : points
Problem Statement
Takahashi is having trouble with deciding a username for a service. Write a code to help him.
Find a string that satisfies all of the following conditions:
- is obtained by the following procedure:- Let be a permutation of . Let be the concatenation of , ( or more copies of
_
), , ( or more copies of_
), , ( or more copies of_
), and , in this order. - Let be a permutation of . Let be the concatenation of , ( or more copies of
_
), , ( or more copies of_
), , ( or more copies of_
), and , in this order. - The length of is between and , inclusive.
- does not coincide with any of strings .
If there is no that satisfies all of the conditions, print -1
instead.
Constraints
- and are integers.
- if .
- is a string consisting of lowercase English letters.
- if .
- is a string consisting of lowercase English letters and
_
.
Input
Input is given from Standard Input in the following format:
Output
Print a string that satisfies all of the conditions. If there is no that satisfies all of the conditions, print -1
instead.
If there are multiple solutions, print any of them.
1 1
chokudai
chokudai
-1
The only string that satisfies the first and second conditions is chokudai
, but it coincides with .
Thus, there is no that satisfies all of the conditions, so -1
should be printed.
2 2
choku
dai
chokudai
choku_dai
dai_choku
Strings like choku__dai
(which has two _
's between choku
and dai
) also satisfy all of the conditions.
2 2
chokudai
atcoder
chokudai_atcoder
atcoder_chokudai
-1
chokudai__atcoder
and atcoder__chokudai
(which have two _
's between chokudai
and atcoder
) have a length of , which violates the second condition.
4 4
ab
cd
ef
gh
hoge
fuga
____
_ab_cd_ef_gh_
ab__ef___cd_gh
The given may contain a string that cannot be obtained by the procedure described in the first condition.