#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
using namespace std;

int inf = 1e17;

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for(int &z : x) cin >> z;
    cout << x[0]*(n-m%2) << endl;
}

signed main()
{
    int t;
    cin >> t;
    for(int i = 0; i < t; ++i) solve();
}