#include <bits/stdc++.h>
#define int long long

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int t;
    cin >> t;
    for(int p = 0; p < t; ++p){
        int n, m;
        cin >> n >> m;
        int val;
        for(int i = 0; i < m; ++i)
            cin >> val;

        if(n >= m){
            cout << m * val << endl;
            continue;
        }
        if((m - n) % 2 == 0)
            cout << n * val << endl;
        else
            cout << (n - 1) * val << endl;
    }
}