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 = "import sys\r\n\r\ndef minshift(s):\r\n\ts += s\r\n\tn = len(s)\r\n\ti, ans = 0, 0\r\n\twhile i < n//2:\r\n\t\tans = i\r\n\t\tj, k = i+1, i\r\n\t\twhile j<n and s[k] <= s[j]:\r\n\t\t\tif s[k] < s[j]:\r\n\t\t\t\tk = i\r\n\t\t\telse:\r\n\t\t\t\tk += 1\r\n\t\t\tj += 1\r\n\r\n\t\twhile i <= k:\r\n\t\t\ti += j-k\r\n\r\n\treturn s[ans:ans + n//2]\r\n\r\nt = int(sys.stdin.readline().strip())\r\nfor _ in range(t):\r\n\tl, s = sys.stdin.readline().strip().split()\r\n\tl = int(l)\r\n\r\n\tarr = [0]*len(s)\r\n\tfor i in range(len(s)):\r\n\t\tarr[i] = s[i]\r\n\r\n\tif l >= 2:\r\n\t\tarr.sort()\r\n\t\tprint(*arr, sep='')\r\n\t\tprint('')\r\n\telse:\r\n\t\tprint(minshift(s))\r\n\r\n\t\t# minalph = min(arr)\r\n\r\n\t\t# pos = []\r\n\r\n\t\t# for i in range(len(s)):\r\n\t\t# \tif s[i] == minalph:\r\n\t\t# \t\tpos += [i]\r\n\r\n\t\t# # print(pos)\r\n\r\n\t\t# offset = 1\r\n\t\t# while True:\r\n\t\t# \ttempmin = 'z'\r\n\t\t# \tfor i in range(len(pos)):\r\n\t\t# \t\ttempmin = min(tempmin, s[(pos[i]+offset)%len(s)])\r\n\r\n\t\t# \ttemppos = []\r\n\t\t# \tfor i in range(len(pos)):\r\n\t\t# \t\tif s[(pos[i]+offset)%len(s)] == tempmin:\r\n\t\t# \t\t\ttemppos += [pos[i]]\r\n\r\n\t\t# \tpos = temppos[:]\r\n\t\t# \toffset += 1\r\n\t\t# \t# print(offset)\r\n\t\t# \t# print(pos)\r\n\r\n\t\t# \tif tempmin == minalph:\r\n\t\t# \t\tbreak\r\n\r\n\t\t# start = pos[0]\r\n\t\t# for i in range(len(s)):\r\n\t\t# \tprint(s[(start+i)%len(s)], end='')\r\n\t\t# print('')"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13473