#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("02")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define int long long
/*int gcd(int a, int b, int &x, int &y){
    //cout << a << " " << b << "\n";
    if (a == 0){
        x = 0y = 1;
        return b;
    }
    int x1, y1;
    int d = gcd(b % a, a, x1, y1);
    x = y1 - b / a * x1;
    y = x1;
    return d;
}*/
const int inf = 1e18 + 7;
void solve(){
    int n, m;
    cin >> n >> m;
    vector<int> x(m + 1);
    for (int i = 1; i <= m; i++){
        cin >> x[i];
    }
    int ans = 0;
    for (int i = 1; i <= min(n, m); i++){
        ans += x[i];
    }
    if (n > m){
        cout << ans << "\n";
        return;
    }
    if ((m - min(n, m)) % 2 == 1){
        ans -= x[0];
    }
    cout << ans << "\n";
}
signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--){
        solve();
    }


}
