#include "bits/stdc++.h"
//#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define ff first
#define ss second

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> v1, v2;
    int cnt1 = 0, cnt2 = 0, cnt0 = 0;
    for (int i = 0; i < m; i++) {
        int x;
        cin >> x;
        if (x >= 0) {
            cnt1++;
            v1.push_back(x);
        } else {
            cnt2++;
            v2.push_back(x);
        }
    }

    if (n == 1){
        if (m % 2 == 0){
            cout << 0;
        } else {
            cout << v1[0];
        }
    } else {
        cout << v1[0];
    }
    cout << '\n';

}

signed main() {
    ios_base::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
}