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