Given a string str, find the longest repeating non-overlapping substring in it. In other words find 2 identical substrings of maximum length which do not overlap. If there exists more than one such substring return any of them.
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains an integer N denoting the length of the string str.
The second line of each test case contains the string str.It consists of only lower case english alphabets.
Print the longest non - overlapping substring for each test case in a new line. If no such sub - sequence exists print -1.
1<= N <=1000
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.