for _ in range(int(input())): r, s = input().split() for i in s: print(i*int(r),end="") print()