You have a string S consisting of N uppercase English letters. You are allowed to perform at most one operation of following kind: Choose any position in the string, remove the character at that position and insert it back to any other place in the string.

Find the  lexicographically smallest  string you can achieve.

-----Input-----
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains the single integer N denoting length of string S.
The second line contains the string S.

-----Output-----
For each test case, output a single line containing the answer to the corresponding test case.

-----Constraints-----
- 1 ≤ T ≤ 50
- 1 ≤ N ≤ 50
- S will consist of uppercase English letters.

-----Example-----
Input:
2
4
DCBA
7
XYZZYZZ

Output:
ADCB
XYYZZZZ

-----Explanation-----
Example case 1. The optimal solution here is to choose the last character and put it in the beginning of the string. So the answer will be ADCB
Example case 2. The optimal solution here is to choose the 5-th character (1-based index) and put it between the 2-nd and the 3-rd characters. So the answer will be XYYZZZZ

Starter code:

Solutions:
for _1 in range(int(input())):
 n=int(input())
 s=input().strip()
 answer=s
 for i in range(len(s)):
  c=s[i]
  string=s[:i]+s[i+1:]
  for j in range(len(string)+1):
   answer=min(answer, string[:j]+c+string[j:])
 print(answer)

def modify(s,i,j):
 k = s[i]
 del(s[i])
 s.insert(j,k)
 return(str(s))
 
for _ in range(int(input())):
 n = int(input())
 s = list(input())

 ans = str(s)
 for i in range(n):
  for j in range(n):
   if i != j:
    ans = min(ans,modify(s,i,j))
   k = s[j]
   del(s[j])
   s.insert(i,k)
 
 for i in ans:
  if ord(i) >= 65 and ord(i) <=90:
   print(i,end="")
 print()

def Min_str():
 n = int(input())
 s = input()
 temp = s[:]
 for i in range(n):
  s1 = [ord(x) for x in s]
  t = s1[i]
  del s1[i]
  j = 0
  while(j<n-1):
   if(s1[j]>t):
    s1[j:j]=[t]
    break
   j+=1
  if(len(s1)!=n):
   s1+=[t]
  T="".join([chr(x) for x in s1])
  if(T<temp):
   temp = T
 print(temp)
t= int(input())
for i in range(t):
 Min_str()

t=int(input())
for _ in range(t):
 n=int(input())
 s=list(input())
 ans=s
 for i in range(n):
  x=s.copy()
  del(x[i])
  for j in range(n):
   ans=min(ans,x[:j]+[s[i]]+x[j:])
 print("".join(ans))
  
  
 


for _ in range(int(input())):
 n=int(input())
 #s=input() 
 mini=["z"]*100
 s=list(input().strip())
 # n=len(s)
 ans=min(mini,s)
 t=s[:]
 for i in range(n):
  #remove s[i]
  curr=s[i]
  f=0
  ind=0 
  temp=s[i]
  for j in range(i):
   if s[j]>curr:
    s.pop(i)
    s.insert(j,temp)
    ans=min(ans,s)
    break 
  s=t[:] 
  # print(s)
 for i in range(n):
  #remove s[i]
  curr=s[i]
  f=0
  ind=n-1 
  temp=s[i]
  for j in range(i+1,n):
   if s[j]>curr:
    s.pop(i)
    s.insert(j-1,temp)
    ans=min(ans,s)
    break 
  else:
   s.pop(i)
   s.insert(n-1,temp)
   ans=min(ans,s)
  s=t[:] 
 #ans=min(pzbl)
 print(*ans,sep='')
 

t = int(input())
for T in range(t):
 n = int(input())
 s = input()
 ans = s
 val, val1 = '', ''
 for i in range(n):
  ##print(val, end = " ")
  val = s[:i] + s[i + 1:]
  for j in range(n):
   val1 = val[:j] + s[i] + val[j:]
   ##print(val1)
   ans = min(ans, val1)
 print(ans)


# cook your dish here
t = int(input())

for _ in range(t):
 n = int(input())
 s = input()
 l = []
 for i in range(n):
  yo = s[:i] + s[i+1:]
  for j in range(n):
   k1 = yo[:j] + s[i] + yo[j:]
   l.append(k1)
 l.sort()
 print(l[0])


t=int(input())
for _ in range(t):
 n=int(input())
 s=input()
 wow=s
 for i in range(n):
  now=s[:i]+s[i+1:]
  for j in range(n):
   wow=min(wow,now[:j]+s[i]+now[j:])
  
 print(wow)
'''    c=True
    ind=0
    while c and ind<n:
     m=min(s[ind:])
     if m==s[ind:][0]:
      ind+=1
      continue
     else:
      c=False
      if True:
       l=[j+ind for j,i in enumerate(s[ind:]) if i==m]
       #print([s[:ind]+s[aa]+s[ind:aa]+s[aa+1:] for aa in l])
       mm=min(l,key=lambda aa:s[:ind]+s[aa]+s[ind:aa]+s[aa+1:])
      s=s[:ind]+m+s[ind:mm]+s[mm+1:]
    print(s)'''
   
  
 


# cook your dish here
for _ in range(int(input())):
 n=int(input())
 s=input()
 ans=s
 for i in range(n):
  new_s=s[:i]+s[i+1:]
  for j in range(n):
   ans=min(ans,new_s[:j]+s[i]+new_s[j:])
   
 print(ans)

for _ in range(int(input())):
 n=int(input())
 s=input()
 ans=s
 for i in range(n):
  new_s=s[:i]+s[i+1:]
  for j in range(n):
   ans=min(ans,new_s[:j]+s[i]+new_s[j:])
   
 print(ans)