import sys input = sys.stdin.readline T = int(input()) for _ in range(T): K = int(input()) S = input().strip() N = len(S) K%=N print(S[0]*K+S[:-K])