#include<bits/stdc++.h>
using namespace std;
#define int long long

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<int>x(m);
    for(int i = 0; i < m; i++)
    {
        cin >> x[i];
    }
    int ans = x[0] * n;
    if(m >= n && (m - n) % 2 != 0)
    {
        ans -= x[0];
    }
    cout << ans << endl;
}

signed main()
{
    int t;
    cin >> t;
    while(t)
    {
        t--;
        solve();
    }
}