#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<ll> a(n), x(m);
    ll ans = -1e18;
    cout << x[0] * (m % 2) << 
    '\n';
    return;
    for (int i = 0; i < m; ++i) cin >> x[i];
    for (int mask = 0; mask < 1 << m; ++mask) {
        for (int i = 0; i < m; i++) {
            int ind = (mask >> i) & 1;
            a[ind] = x[i] - a[ind];
        }
        ans = max(ans, a[0] + a[1]);
        cout << a[0] + a[1] << ' ';
        a[0] = 0;
        a[1] = 0;
    }
    cout << '\n';
    cout << ans << '\n';
}

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