P8190 [CF2039B] Shohag Loves Strings
入门
题目描述

For a string $p$, let $f(p)$ be the number of distinct non-empty substrings$^{\text{∗}}$ of $p$.

Shohag has a string $s$. Help him find a non-empty string $p$ such that $p$ is a substring of $s$ and $f(p)$ is even or state that no such string exists.

Input

The first line contains a single integer $t$ ($1 \le t \le 10^4$) — the number of test cases.

The first and only line of each test case contains a string $s$ ($1 \le |s| \le 10^5$) consisting of lowercase English letters.

It is guaranteed that the sum of the length of $s$ over all test cases doesn't exceed $3 \cdot 10^5$.

Output

For each test case, print a non-empty string that satisfies the conditions mentioned in the statement, or $-1$ if no such string exists. If there are multiple solutions, output any.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 dcabaac a youknowwho codeforces bangladesh
样例输出
abaa -1 youknowwho eforce bang
提示

In the first test case, we can set $p = $ abaa because it is a substring of $s$ and the distinct non-empty substrings of $p$ are a, b, aa, ab, ba, aba, baa and abaa, so it has a total of $8$ distinct substrings which is even.

In the second test case, we can only set $p = $ a but it has one distinct non-empty substring but this number is odd, so not valid.

In the third test case, the whole string contains $52$ distinct non-empty substrings, so the string itself is a valid solution.