#1238
Unrated
MULTIGRAM
시간 제한
1s
메모리 제한
64MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

1 second, 64 MB, 80 points Pero is a passionate lover of riddles. The newest type of riddles he has come across requires the solver to check whether the given word is a multigram. A multigram is a word that consists of concatenating two or more words that are all mutually ana- grams. The first of these words is called the root of the multigram. For instance, the word bbabab is a multigram with the root bba because it consists of anagrams bba and bab. Help Pero solve the riddle by determining whether his word is a multigram and determining its root in case it is. If there are multiple possible roots of the multigram, output the shortest. Please note: Two words are mutually anagrams if one of them can be obtained from the other by changing the letter order.

입력

The first and only line of input contains a word of length at most 100 000 lowercase English charac- ters.

출력

If the given word is not a multigram, output −1. Otherwise, output the shortest root of the given word in one line.

예제 입력 1

aaaa

예제 출력 1

a

예제 입력 2

ab

예제 출력 2

-1

예제 입력 3

bbabab

예제 출력 3

bba
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.