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 least_rotation(S):\r\n    S += S  # Concatenate string to it self to avoid modular arithmetic\r\n    f = [-1] * len(S)  # Failure function\r\n    k = 0  # Least rotation of string found so far\r\n    for j in range(1, len(S)):\r\n        sj = S[j]\r\n        i = f[j - k - 1]\r\n        while i != -1 and sj != S[k + i + 1]:\r\n            if sj < S[k + i + 1]:\r\n                k = j - i - 1\r\n            i = f[i]\r\n        if sj != S[k + i + 1]:  # if sj != S[k+i+1], then i == -1\r\n            if sj < S[k]:  # k+i+1 = k\r\n                k = j\r\n            f[j - k] = -1\r\n        else:\r\n            f[j - k] = i + 1\r\n    return k\r\n\r\ntest = int(input())\r\nfor tc in range(test):\r\n    l,st = input().split()\r\n    l=int(l)\r\n    if l==1:\r\n        kk = least_rotation(st)\r\n        ln = len(st)\r\n        mt = ""\r\n        for i in range(len(st)):\r\n            mt+=str(st[(kk+i)%ln])\r\n        print(mt)\r\n    else:\r\n        lst = []\r\n        for i in range(len(st)):\r\n            lst.append(st[i])\r\n        lst.sort()\r\n        mt = ""\r\n        for i in range(len(lst)):\r\n            mt+=str(lst[i])\r\n        print(mt)'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13489