Given a string S. The task is to find the first repeated character in it. We need to find the character that occurs more than once and whose index of second occurrence is smallest. S contains only lowercase letters.
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains a string S.
For each test case in a new line print the first repeating character in the string. If no such character exist print -1.
1 <= T <= 100
1 <= |S| <=104
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.