#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define size(t) (int)t.size()
#define pb push_back
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()

using namespace std;

const int N = 3e5 + 5;

int a[N];

void solve() {
    int n, m, i, j;
    cin >> n >> m;
    int mx = 0;
    for (i = 1; i <= m; i++) {
        cin >> a[i];
        mx = max(mx, a[i]);
    }
    if (n < m && n % 2 != m % 2) {
        n --;
    }
    cout << (ll)mx * n << '\n';
}

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


