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

using namespace std;
using namespace __gnu_pbds;

//#define int long long
using ll = long long;

typedef tree<int, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int inf = 1e9 + 7;
const ll inf_ = 1e18 + 7;
const int mod = 998244353;

struct Hash {
    int mod2 = 1e9 + 7, p2 = 239;

    int sum(int a, int b) {
        a += b;
        if (a >= mod2) a -= mod2;
        return a;
    }

    int sub(int a, int b) {
        a -= b;
        if (a < 0) a += mod2;
        return a;
    }

    int mul(int a, int b) {
        return a * 1ll * b % mod2;
    }

    vector<int> h, pr;

    Hash(string s) {
        int n = s.size();
        h.resize(n);
        pr.resize(n + 1);
        h[0] = s[0];
        pr[0] = 1;
        for (int i = 1; i < n; i++)
            h[i] = sum(s[i], mul(h[i - 1], p2));
        for (int i = 1; i <= n; i++)
            pr[i] = mul(pr[i], p2);
    }

    int get(int l, int r) {
        return 0;
    }
};

struct Fast {
    void solve() {
        int n, m;
        cin >> n >> m;
        vector<int> b(m);
        for (auto &i: b) cin >> i;
        if (n >= m) cout << n * b[0];
        else cout << n * b[0] - (n % 2 != m % 2) * b[0];
    }
};

signed main() {
    int __ = 1;
    cin >> __;
    while (__--) {
        Fast().solve();
        cout << '\n';
    }
    return 0;
}
