def concatenate_and_maximize(A, N, K):
A = list(map(str, A)) # Convert to strings for concatenation
for _ in range(K):
max_value = ''
best_index = -1
# Find the best adjacent pair to concatenate
for i in range(len(A) - 1):
new_value = A[i] + A[i + 1]
if new_value > max_value:
max_value = new_value
best_index = i
if best_index == -1:
break
# Perform the concatenation
A[best_index] = max_value
del A[best_index + 1] # Remove the second part of the concatenated pair
# After all operations, find and return the maximum value 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(concatenate_and_maximize(A, N, K))