Saraga

시간 제한1초메모리 제한2048 MB

요약
S의 접두사와 T의 접미사로 이루어진 분할이 두 가지 이상 존재하는 가장 짧은 문자열을 찾는다.
난이도

보통10점 중 7점

유형
문자열, 문자열 매칭
정답자
아직 제출이 없습니다

문제

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.

입력

The first line consists of a string SS (1≤∣S∣≤200,0001 ≤ |S| ≤ 200\\, 000).

The second line consists of a string TT (1≤∣T∣≤200,0001 ≤ |T| ≤ 200\\, 000).

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

예제4

  1. 예제 1

    입력
    sarana
    olahraga
    
    예상 출력
    saga
    
  2. 예제 2

    입력
    berhiber
    wortelhijau
    
    예상 출력
    berhijau
    
  3. 예제 3

    입력
    icpc
    icpc
    
    예상 출력
    icpc
    
  4. 예제 4

    입력
    icpc
    jakarta
    
    예상 출력
    -1