#include <bits/stdc++.h>

using namespace std;
#define int long long


signed main() {
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--) {
        int n, m;
        cin >> m >> n;
        vector<int> x(n);
        for (int i = 0; i < n; i++) {
            cin >> x[i];
        }
        int ans = (m - 1) * x[0] + (n - (m - 1) > 2);
        cout << ans;
    }
    return 0;
}