#include <bits/stdc++.h>

using namespace std;

#define int long long
using ld = long double;
using ll = long long;
using pii = pair<int, int>;

void solve()
{
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; ++i)
        cin >> x[i];
    int c = min(n, m);
    int ans = 0;
    for (int i = 0; i < c; ++i)
        ans += x[0];
    cout << ans << '\n';
}

signed main()
{
#ifdef ROMALOCAL
    freopen("in.txt", "r", stdin);
#endif

    cin.tie(0);
    ios::sync_with_stdio(0);

    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}