#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

#define int ll
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using ordered_set = __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

mt19937 rnd(time(0));

inline void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for (auto &x: a) cin >> x;
    if (m <= n) {
        cout << m * a[0] << "\n";
        return;
    }
    if ((m - n) % 2) {
        cout << (n - 1) * a[0] << "\n";
    } else {
        cout << n * a[0] << "\n";
    }
}

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