#include <bits/stdc++.h>

#define ll long long

using namespace std;

void fast_in_out() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
ll n,i,x[300010],m,j;
const ll inf=1e18;
int main() {
    fast_in_out();
    ll t;
    cin >> t;
    while(t--){
        cin >> n >> m;
        for(i=m;i>=1;i--)cin >> x[i];
        m%=2*n;
        cout << x[1]*(min(n,m)-max(0ll,m-n)) << '\n';
    }
    return 0;
}
