T = int(input())
p = []
for i in range(T):
a, b = input().split()
a = int(a)
for i in range(len(b)):
p.append(a*b[i])
for i in p:
print(i, end='')
p = []
VCA9IGludChpbnB1dCgpKQoKcCA9IFtdCgpmb3IgaSBpbiByYW5nZShUKToKICAgIGEsIGIgPSBpbnB1dCgpLnNwbGl0KCkKICAgIGEgPSBpbnQoYSkKICAgIGZvciBpIGluIHJhbmdlKGxlbihiKSk6CiAgICAgICAgcC5hcHBlbmQoYSpiW2ldKSAgICAgICAKICAgIGZvciBpIGluIHA6CiAgICAgICAgcHJpbnQoaSwgZW5kPScnKQogICAgcCA9IFtdCg==