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