logo AlgoBeat OnlineJudge
登录 注册

#215725. [ICPC 2024 Jakarta R] Saraga

内存限制:1024 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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 and 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 and the second substring is a suffix of .

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

输入格式

The first line consists of a string ( ).

The second line consists of a string ( ).

Both strings and only consist of lowercase English letters.

输出格式

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 and with minimum length. If there are multiple solutions, output any of them.

样例

样例输入 1

sarana
olahraga

样例输出 1

saga

样例输入 2

berhiber
wortelhijau

样例输出 2

berhijau

样例输入 3

icpc
icpc

样例输出 3

icpc

样例输入 4

icpc
jakarta

样例输出 4

-1

数据范围与提示

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.