Non-repeating

0

0 votes
Problem

Problem

Given a string find the first character in the string from left which is non-repeating i.e occurs no more than once in the entire string.

Input

First line contains T denoting the number of test cases. Then T lines follow each containing a string made up of lower case characters.

Output

For each test case output in a new line the first character from left of the string that occurs only once in the entire string. If there is no such unique character print -1 instead.

Constraints

  • 1 <= T <= 103
  • 1 <= size of the string <= 104
Sample Input
2

adbddca
cceefcfqrrs
Sample Output
b
q
Time Limit: 1
Memory Limit: 256
Source Limit:
Contributers:
Editor Image

?