T = int(input()) for _ in range(T): K = int(input()) S = input() if K < len(S): for _ in range(K): S = S[0] + S[:-1] else: S = S[0] * len(S) print(S)