You are given a string $S$ and an integer $L$. A operation is described as :- "You are allowed to pick any substring from first $L$ charcaters of $S$, and place it at the end of the string $S$. 
A string $A$ is a substring of an string $B$ if $A$ can be obtained from $B$ by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) elements from the end.
Find the lexographically smallest string after performing this opertaion any number of times (possibly zero).
For example $S$ = "codechef" and $L=4$. Then, we can take substring "ode" from S[0-3] and place it at end of the string $S$ = "cchefode".

-----Input:-----
- First line will contain $T$, number of testcases. 
- Then each of the N lines contain an integer $L$ and a string $S$. 

-----Output:-----
For each testcase, output in a single line answer lexographically smallest string.

-----Constraints-----
- $1 \leq T \leq 10^4$
- $2 \leq |S| \leq 10^3$
- $1 \leq L \leq N $

-----Sample Input:-----
2
1 rga
2 cab

-----Sample Output:-----
arg
abc

-----EXPLANATION:-----
In the first testcase:
substring 'r' is picked and placed at the end of the string. rga -> gar
Then performing same operation gives :- gar -> arg

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = "def solve(s,l,ans):\r\n    n = len(s)\r\n    s = list(s)\r\n    if l > 1:\r\n        s.sort()\r\n        ans.append(s)\r\n        return\r\n    \r\n    indices = []\r\n    min_val = min(s)\r\n    for i in range(len(s)):\r\n        if s[i] == min_val:\r\n            indices.append((i,1))\r\n\r\n\r\n    while True:\r\n        min_val = 'z'\r\n        found = False\r\n        for index,count in indices:\r\n            min_val = min(min_val,s[index])\r\n            if count == n:\r\n                found = True\r\n                \r\n        if found:\r\n            break\r\n\r\n        new_indices = []\r\n        for index,count in indices:\r\n            if s[index] == min_val:\r\n                if index+1 == n:\r\n                    new_indices.append((0,count+1))\r\n                else:\r\n                    new_indices.append((index+1,count+1))\r\n\r\n        indices = new_indices[:]\r\n\r\n    s1 = []\r\n    index = indices[0][0]\r\n    count = 0\r\n    while index >= 0:\r\n        s1.append(s[index])\r\n        count += 1\r\n        index -= 1\r\n\r\n    index = n-1\r\n    while count != n:\r\n        s1.append(s[index])\r\n        index -= 1\r\n        count += 1\r\n\r\n    s1.reverse()\r\n    ans.append(s1)\r\n\r\ndef main():\r\n    t = int(input())\r\n    ans = []\r\n    for i in range(t):\r\n        l,s = map(str,input().split())\r\n        l = int(l)\r\n        solve(s,l,ans)\r\n\r\n    for i in ans:\r\n        for j in i:\r\n            print(j,end = '')\r\n\r\n        print()\r\n\r\n\r\nmain()\r\n"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13613