#P9868. E. Subsequence Not Substring
E. Subsequence Not Substring
E. Subsequence Not Substring
Problem Description
Given a string consisting of only lowercase latin letters。 Find the lexicographic smallest string , satisfying is a subsequence of , but is not a substring of , or determine such doesn't exist.
Input
The input consists of multiple test cases. The first line contains a single integer () - the number of test cases. Description of the test cases follows. The first line of each test case contains one string (). It's guaranteed that .
Output
For each test case, print a single string , satisfying is a subsequence of , but is not a substring of . If such doesn't exist, print -1
.
It's guaranteed that .
Sample Input
4
bbacb
aaabaaba
gugguggguggggu
zzzzzzzzzzzzzzzz
Sample Output
ab
aaaa
ggggg
-1
Source
2023“钉耙编程”中国大学生算法设计超级联赛(7)