#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <fstream>
#include <bitset>
#include <string>

//#pragma GCC optimize("unroll-loops,inline,O2,O3,Ofast")
//#pragma GCC target("avx,avx2,bmi,bmi2,sse,sse2,sse3,sse4,ssse3,abm,mmx,fma,popcnt,lzcnt")

using namespace std;

typedef long long ll;

ll INF = 1e18 + 9;

void solve() {

    ll n, m;
    cin >> n >> m;

    vector<ll> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i];
    }

    if (m % 2 || n > 1) {
        cout << a[0] * n;
    } else {
        cout << 0;
    }
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ll t = 1;
    cin >> t;
    while (t--) {
        solve();
        cout << "\n";
    }

    return 0;
}
