def solve(): K = int(input()) S = input() for _ in range(K): S = S[0] + S S = S[:-1] print(S) T = int(input()) for _ in range(T): solve()