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: str) -> int:\r\n    """Booth\'s algorithm."""\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\n\r\nfor _ in range(int(input())):\r\n    l, s = input().split()\r\n    if int(l) == 1:\r\n        l = len(s)\r\n        s += s\r\n        k = least_rotation(s)\r\n        print(s[k:k+l])\r\n    else:\r\n        print(\'\'.join(sorted(s)))'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13311