def max_possible_number(N, K, A):
A = list(map(str, A)) # Convert all numbers to strings for easy concatenation
for _ in range(K):
max_num = ''
index = -1
# Find the best pair to concatenate
for i in range(N-1):
new_num = A[i] + A[i+1]
if new_num > max_num:
max_num = new_num
index = i
if index == -1:
break
# Replace the pair with the new concatenated number
A[index] = max_num
A.pop(index+1)
N -= 1
# Return the maximum number in the array
return max(A)
# Reading input
T = int(input())
for _ in range(T):
N, K = map(int, input().split())
A = list(map(int, input().split()))
print(max_possible_number(N, K, A))