#include<bits/stdc++.h>
#define debug(x) cerr << #x << " = " << x << "\n";
#define debug_v(x) cerr << #x << " ="; for(auto i : x) {cerr << " [" <<  i << "]";} cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
const double PI = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 1e18 + 100;
void solve(){
	int n, k, answer = 0;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	for (int i = 1; i <= (1 << n); i++){
		if(__builtin_popcount(i) == k){
			int temp = 0;
			for (int j = 0; j < n; j++){
				if(i & (1 << j)){
					temp ^= a[j];
				}
			}
			answer = max(answer, temp);
		}
	}
	cout << answer << "\n";
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(20);
	int t;
	cin >> t;
	while(t--){
		solve();
	}
	return 0;
}
