问题 E: Subsequence Not Substring

内存限制:512 MB 时间限制:7 S
题面:传统 评测方式:文本比较 上传者:
提交:2 通过:1

题目描述

Given a string S consisting of only lowercase latin letters。

Find the lexicographic smallest string T, satisfying T is a subsequence of SS, but T is not a substring of S, or determine such T doesn't exist.

 

输入格式

The input consists of multiple test cases. The first line contains a single integer T (1T2×10^5) - the number of test cases. Description of the test cases follows.

The first line of each test case contains one string S (1S10^5).

It's guaranteed that S5×10^6.

输出格式

For each test case, print a single string T, satisfying T is a subsequence of S, but T is not a substring of S. If such T doesn't exist, print -1.

It's guaranteed that T2×10^6.

输入样例 复制

4
bbacb
aaabaaba
gugguggguggggu
zzzzzzzzzzzzzzzz

输出样例 复制

ab
aaaa
ggggg
-1

分类标签