#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("O3")

using namespace std;
//using namespace __gnu_pbds;

mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define int long long

//typedef tree<int, null_type,less<int>,  rb_tree_tag, tree_order_statistics_node_update> ordered_set;

void solve(){
    int n, m;
    cin>>n>>m;
    vector<int> x(m);
    for(auto &y:x) cin>>y;
    if (n == 1){
        cout<<(m%2)*x[0]<<'\n';
    }
    else{
        cout<<x[0]+(m%2 == 0)*x[0]<<'\n';
    }
}

signed main(){
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#ifdef YA_KRUTOI
    freopen("input.txt", "r", stdin);
#endif
    int t;
    cin>>t;
    while(t--) solve();
    return 0;
}
