#include <iostream>
//#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
//#include <map>
//#include <cmath>

using namespace std;

typedef long long ll;
//typedef long double ld;

#define int long long
#define ff first
#define ss second
#define endl '\n'
#define all(a) (a).begin, (a).end()

const int INF = 1e18 + 123;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; ++i) {
        cin >> x[i];
    }

    if (n % 2 == m % 2 || m <= n) {
        cout << x[0] * n << endl;
    } else {
        cout << x[0] * (n - 1) << endl;
    }
}
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

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