#include <bits/stdc++.h>
using namespace std;
#define int long long


void solve(){
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    int ans = 0;
    for (int i = 0; i < m; ++i){
        cin >> x[i];
    }
    if (m % 2){
        cout << x[0] << "\n";
    }
    else{
        cout << "0\n";
    }
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int nerpa; cin >> nerpa;
    while(nerpa--){
        solve();
    }
}
