#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;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBkZWJ1Zyh4KSBjZXJyIDw8ICN4IDw8ICIgPSAiIDw8IHggPDwgIlxuIjsKI2RlZmluZSBkZWJ1Z192KHgpIGNlcnIgPDwgI3ggPDwgIiA9IjsgZm9yKGF1dG8gaSA6IHgpIHtjZXJyIDw8ICIgWyIgPDwgIGkgPDwgIl0iO30gY2VyciA8PCAiXG4iOwp1c2luZyBuYW1lc3BhY2Ugc3RkOwp1c2luZyBsbCA9IGxvbmcgbG9uZzsKdXNpbmcgbGQgPSBsb25nIGRvdWJsZTsKY29uc3QgZG91YmxlIFBJID0gYWNvcygtMSk7CmNvbnN0IGludCBtb2QgPSAxZTkgKyA3Owpjb25zdCBpbnQgaW5mID0gMWU5ICsgMTAwOwpjb25zdCBsbCBpbmY2NCA9IDFlMTggKyAxMDA7CnZvaWQgc29sdmUoKXsKCWludCBuLCBrLCBhbnN3ZXIgPSAwOwoJY2luID4+IG4gPj4gazsKCXZlY3RvcjxpbnQ+IGEobik7Cglmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKyl7CgkJY2luID4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