Masala C

Xotira 32 MB Vaqt 1000 ms
14

Saraga

The word saraga is an abbreviation of sarana olahraga, an Indonesian term for a sports facility. It is created by taking the prefix sara of the word sarana and the suffix ga of the word olahraga. Interestingly, it can also be created by the prefix sa of the word sarana and the suffix raga of the word olahraga.

An abbreviation of two strings SS and TT is interesting if there are at least two different ways to split the abbreviation into two non-empty substrings such that the first substring is a prefix of SS and the second substring is a suffix of TT.

You are given two strings SS and TT. You want to create an interesting abbreviation of strings SS and TT with minimum length, or determine if it is impossible to create an interesting abbreviation.


Kiruvchi ma'lumotlar:

The first line consists of a string S(1S200000).S (1≤|S|≤200000).

The second line consists of a string T(1T200000).T (1≤|T|≤200000).

Both strings SS and TT only consist of lowercase English letters.


Chiquvchi ma'lumotlar:

If it is impossible to create an interesting abbreviation, output -1.

Otherwise, output a string in a single line representing an interesting abbreviation of strings SS and \(T\0 with minimum length. If there are multiple solutions, output any of them.


Misollar
# input.txt output.txt
1
sarana
olahraga
saga
2
berhiber
wortelhijau
berhijau
3
icpc
icpc
icpc
4
icpc
jakarta
-1
Izoh:

Explanation for the sample input/output #1

You can split saga into s and aga, or sa and ga. The abbreviation saraga is interesting, but saga has a smaller length.

Explanation for the sample input/output #2

The abbreviation belhijau is also interesting with minimum length, so it is another valid solution.